Codeforces Round #568 (Div. 2) B. Email from Polycarp
链接:
https://codeforces.com/contest/1185/problem/B
题意:
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).
For example, as a result of typing the word "hello", the following words could be printed: "hello", "hhhhello", "hheeeellllooo", but the following could not be printed: "hell", "helo", "hhllllooo".
Note, that when you press a key, the corresponding symbol must appear (possibly, more than once). The keyboard is broken in a random manner, it means that pressing the same key you can get the different number of letters in the result.
For each word in the letter, Methodius has guessed what word Polycarp actually wanted to write, but he is not sure about it, so he asks you to help him.
You are given a list of pairs of words. For each pair, determine if the second word could be printed by typing the first one on Polycarp's keyboard.
思路:
将每个字符串对应的字母和相连次数存下来,比较一下即可。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
int n, m, k, t;
vector<pair<char, int> > inp;
vector<pair<char, int> > out;
string a, b;
bool Solve()
{
if (inp.size() != out.size())
return false;
for (int i = 0;i < inp.size();i++)
{
if (inp[i].first != out[i].first)
return false;
if (inp[i].second > out[i].second)
return false;
}
return true;
}
int main()
{
cin >> t;
while (t--)
{
inp.clear(), out.clear();
cin >> a >> b;
int tmp = 0;
for (int i = 0;i <= a.length();i++)
{
if (i == a.length() || (i > 0 && a[i] != a[i-1]))
inp.emplace_back(a[i-1], tmp), tmp = 0;
tmp++;
}
tmp = 0;
for (int i = 0;i <= b.length();i++)
{
if (i == b.length() || (i > 0 && b[i] != b[i-1]))
out.emplace_back(b[i-1], tmp), tmp = 0;
tmp++;
}
// for (auto pa:inp)
// cout << pa.first << ' ' << pa.second << endl;
if (Solve())
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
Codeforces Round #568 (Div. 2) B. Email from Polycarp的更多相关文章
- Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)
题目:http://codeforces.com/contest/1185/problem/G1 题意:给你n给选项,每个选项有个类型和价值,让你选择一个序列,价值和为m,要求连续的不能有两个相同的类 ...
- Codeforces Round #568 (Div. 2) G2. Playlist for Polycarp (hard version)
因为不会打公式,随意就先将就一下? #include<cstdio> #include<algorithm> #include<iostream> #include ...
- Codeforces Round #568 (Div. 2)B
B. Email from Polycarp 题目链接:http://codeforces.com/contest/1185/problem/B 题目: Methodius received an e ...
- codeforces Round #568(Div.2)A B C
有点菜,只写出了三道.活不多说,上题开干. A. Ropewalkers Polycarp decided to relax on his weekend and visited to the per ...
- Codeforces Round #568 (Div. 2)A
A. Ropewalkers 题目链接:http://codeforces.com/contest/1185/problem/A 题目: Polycarp decided to relax on hi ...
- Codeforces Round #568 (Div. 2) A.Ropewalkers
链接: https://codeforces.com/contest/1185/problem/A 题意: Polycarp decided to relax on his weekend and v ...
- Codeforces Round #568 (Div. 2) D. Extra Element
链接: https://codeforces.com/contest/1185/problem/D 题意: A sequence a1,a2,-,ak is called an arithmetic ...
- Codeforces Round #568 (Div. 2) C2. Exam in BerSU (hard version)
链接: https://codeforces.com/contest/1185/problem/C2 题意: The only difference between easy and hard ver ...
- Codeforces Round #568 Div. 2
没有找到这场div3被改成div2的理由. A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long ...
随机推荐
- win server2012r2上发布网站常见错误 "HTTP 错误 500.19 请求的页面的相关配置数据无效" 解决办法
HTTP 错误 500.19 - Internal Server Error无法访问请求的页面,因为该页的相关配置数据无效. 问题“详细错误信息模块 IIS Web Core通知 BeginReque ...
- 做筛选遍历时遇到的json字符串、json对象、json数组 三者之间的转换问题
这个是后台对登录用户以及筛选条件的操作 @Override public List<SdSdPer> listResults(String sidx, String sord) { try ...
- 关系/对象映射 多对多关系(@ManyToMany 注释)【重新认识】
old: @ManyToMany 注释:表示此类是多对多关系的一边, mappedBy 属性定义了此类为双向关系的维护端, 注意:mappedBy 属性的值为此关系的另一端的属性名. 例如,在Stud ...
- 应用安全 - Java - 插件 - IO - excel-streaming-reader - 漏洞汇总
xlsx-streamer.jar的XXE漏洞 Date 类型XXE 影响范围 xlsx-streamer.jar-2.0.0及以下版本 复现
- Metinfo5.1 /message/access.php SQL注入漏洞
- Layer 弹出层抖动问题
layer.open({ type: 2, anim: 5,//加上anim,渐显 title: '品牌列表', shadeClose: fal ...
- Angular5 *ngIf 和 hidden 的区别
问题 项目中遇到一个问题,有一个过滤查询的面板,需要通过一个展开折叠的button,来控制它的show 和 hide.这个面板中,有一个Select 组件,一个 input 查询输入框. 原来代码是: ...
- [转帖]目标管理的S.M.A.R.T.理念
目标管理的S.M.A.R.T.理念 https://blog.csdn.net/gehantao/article/details/1593510 目标管理(MBO)是一种管理战略,它使用的是S ...
- Maven build 命令介绍(转)
常用命令: 打包:mvn package编译:mvn compile清空:mvn clean(清除编译后目录,默认是target目录)运行测试:mvn test安装jar包到本地仓库中:mvn ins ...
- 编辑器IDE之VSCode
很多时候面临换项目组,公司内部换等等,需要清除之前的权限,电脑更换等... 确实很烦人,所以记录也是给自己下次更加快速方便的使用 插件安装 个人常用的一些插件,发现好用的会更新 插件名 功能 vsco ...