当前位置: 首页 > news >正文

Codeforces Round 993B. Normal Problem

如何查找这道题,只需要打开一个问题,然后拷贝链接地址,修改里面的数字为2044就可以了。

例如:https://codeforces.com/contest/2044/problem/B

的确有时候不知道怎么找,我也是最近发现的。

/*
A string consisting of only characters p,q,and w is painted on a glass window of a store.
Ship walks past the store,standing directly in front of the glass window,
and observes string A.
Ship then heads insert the store,looks directly at the same glass window,
and observes string b.
Ship gives you string  A,your job is to find and output B.

Input
The first line contains an integer t(1≤t≤100) — the number of test cases.
The only line of each test case contains a string a(1≤ | a | ≤100)
— the string Ship observes from outside the store.
It is guaranteed that a only contains characters 'p', 'q', and 'w'.

Output
For each test case, output string b, the string Ship observes from inside the store,
on a new line.
Example
Input
5
qwq
ppppp
pppwwwqqq
wqpqwpqwwqp
pqpqpqpq

Output
pwp
qqqqq
pppwwwqqq
qpwwpqwpqpw
pqpqpqpq
*/

/*

根据题意,从窗户外面看到一个字符串,然后需要你给出窗户里面的字符串是什么?

字符的内容是q,p,w三个字母组成。

根据例子,分析如下,在窗户里面,就是倒着,即从后往前,或者说从右边到前面。

这样,p就等于q,而q就等于p,而w不改变。仅此规则。
Note:1 from right to left.  2 p=q,or q=p, w is not change

由于是国外网站,我在程序里面尽量用英文。
*/

思路很简单,得到输入,然后立刻倒着输出,并且遇到q就改写为p,遇到p就改写为q,而w不改变,

非常容易。我用简单的方法:一边输入一边输出。这种情况可以被AC, 也可以集体输出,需要使用vector<string> list来存储输出结果,最后显示即可。


/*
A string consisting of only characters p,q,and w is painted on a glass window of a store.
Ship walks past the store,standing directly in front of the glass window,
and observes string A.
Ship then heads insert the store,looks directly at the same glass window,
and observes string b.
Ship gives you string  A,your job is to find and output B.Input
The first line contains an integer t(1≤t≤100) — the number of test cases.
The only line of each test case contains a string a(1≤ | a | ≤100)
— the string Ship observes from outside the store.
It is guaranteed that a only contains characters 'p', 'q', and 'w'.Output
For each test case, output string b, the string Ship observes from inside the store,
on a new line.
Example
Input
5
qwq
ppppp
pppwwwqqq
wqpqwpqwwqp
pqpqpqpqOutput
pwp
qqqqq
pppwwwqqq
qpwwpqwpqpw
pqpqpqpq
*//*
Note:1 from right to left.  2 p=q,or q=p, w is not change
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{int t = 0;string str1 = "",str2="";const char c_q = 'q';const char c_p = 'p';cin >> t;getchar();while (t--){getline(cin, str1);for (int i = str1.length()-1; i >= 0; i--){if (str1[i] == c_q){str2 += c_p;}else if (str1[i] == c_p){str2 += c_q;}else{str2 += str1[i];}}cout << str2<<endl;str2.clear();}return 0;
}

最后一次输出,用vector<string> list存放输出


/*
A string consisting of only characters p,q,and w is painted on a glass window of a store.
Ship walks past the store,standing directly in front of the glass window,
and observes string A.
Ship then heads insert the store,looks directly at the same glass window,
and observes string b.
Ship gives you string  A,your job is to find and output B.Input
The first line contains an integer t(1≤t≤100) — the number of test cases.
The only line of each test case contains a string a(1≤ | a | ≤100)
— the string Ship observes from outside the store.
It is guaranteed that a only contains characters 'p', 'q', and 'w'.Output
For each test case, output string b, the string Ship observes from inside the store,
on a new line.
Example
Input
5
qwq
ppppp
pppwwwqqq
wqpqwpqwwqp
pqpqpqpqOutput
pwp
qqqqq
pppwwwqqq
qpwwpqwpqpw
pqpqpqpq
*//*
Note:1 from right to left.  2 p=q,or q=p, w is not change
*/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{int t = 0;string str1 = "",str2="";vector<string> rslist;const char c_q = 'q';const char c_p = 'p';cin >> t;getchar();while (t--){getline(cin, str1);for (int i = str1.length()-1; i >= 0; i--){if (str1[i] == c_q){str2 += c_p;}else if (str1[i] == c_p){str2 += c_q;}else{str2 += str1[i];}}//cout << str2<<endl;rslist.push_back(str2);str2.clear();}for (int i = 0; i < rslist.size();i++){cout << rslist[i] << endl;}return 0;
}

http://www.dtcms.com/a/430871.html

相关文章:

  • 《嵌入式 – GD32开发实战指南(RISC-V版本)》第3章 GPIO流水灯的前世今生
  • 深圳手机网站建设哪家好表白链接生成器
  • GameObject 常见类型详解 -- 光环生成对象(AURA GENERATOR)
  • 29.CSS 3D 加载转轮 | CSS 动画效果
  • 潍坊制作网站用淘宝做公司网站
  • AMQP协议深度解析:消息队列背后的通信魔法
  • CSP-J/S复赛真实考试场景还原与备考策略
  • 攻防世界-Web-inget
  • flex布局学习记录
  • unordered_map和unordered_set的使用以及哈希表的实现
  • Powershell 管理 后台/计划 作业(六)
  • 北京网站建设公司东为企业网络营销方案策划书
  • 四川网站营销seo什么价格网站建设哪家g
  • k8s-pod的镜像升级与回滚
  • Django 从入门到进阶:构建完整的博客系统
  • XYplorer(多标签文件管理器) 多语便携版
  • 哈尔滨公告最新消息枣庄seo推广
  • 从输入网址到网页呈现:深入理解 HTTP 及其背后的网络世界
  • 建设一个网站需要什么软件抖音小程序在哪里找
  • Rust语言简介
  • 【无标题】Heartbeat高可用配置实践
  • 【LangChain】P6 对话记忆完全指南:从原理到实战(中)
  • 怎样才能把网站做好app开发制作软件
  • 石家庄网站建设外包公司工艺品网站模版
  • 【LaTeX】 5 LaTeX 文档类
  • x64dbg下载安装图文教程(附安装包)
  • pthread_create详解:打开多线程编程的大门
  • DFS 详解(C++版)
  • 如何通过企微SCRM实现高效的客户管理与营销策略?
  • 北京网站建设华网天下买送两年wordpress百度地图插件