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 ...
随机推荐
- Java学习之==>注释、数据类型、变量、运算符
一.注释 在Java中有3种标记注释的方式,最常用的方式是 // ,其注释的内容从 // 开始,到本行结束.但需要注意的是,我们不建议把注释写在代码的尾部(即尾注释),我们建议把注释写在代码的上一行, ...
- nginx启动用户和nginx工作用户要一致
[root@bogon default]# ps aux | grep "nginx: worker process" | awk '{print $1}'rootrootroot ...
- python3.5以后venv创建/激活/退出虚拟环境
1.创建虚拟环境 $ python3 -m venv <环境名称> 2.激活虚拟环境 $ source <环境名称>/bin/activate 3.关闭虚拟环境 $ deact ...
- 双屏显示——NW.js
1.利用w10中的双屏显示设置(扩展模式) 2.Code for second window: var gui = require('nw.gui'); gui.Screen.Init(); win ...
- Flume采集日志
角色 Source 数据来源 (exec, kafka, http…)Channel 数据通道 (memory,file,jdbc)Sink 数据目的地 (kafka,hdfs,es…) Agent ...
- Unity 动画属性
在动画的使用上使用不当的设置往往会造成不可预料的结果. 首先,如果动画自身可以驱动物体移动,那么在Animator组件上必须选择apply root motion,物体的动画位移才能生效,否则动画只能 ...
- nginx配置laravel项目
在/etc/nginx/conf.d下新建一个laravel.conf文件,并编辑 写入如下文件即可 server { listen 80; server_name xxx; root "/ ...
- 面向对象及os模块、socket模块
1.面向对象及面向过程 1)面向过程:核心过程二字,过程即解决问题的步骤,就是先干什么后干什么 基于该思想写程序就好比在这是一条流水线,是一种机械式的思维方式 优点:复杂的过程流程化 缺点:扩展性差 ...
- CF486B OR in Matrix(构造+思维)
CF486B 一道有趣的思维题 由于or的性质可知只要a[i][j]为1那么b中第i行,第j列将都变成1 相反的,如果b[i][j]是0那么a中第i行,第j列都必须是0 根据第二个性质我们可以构造出a ...
- 常用邮件SMTP POP3服务器地址大全
#阿里云邮箱(mail.aliyun.com): POP3服务器地址:pop3.aliyun.com(SSL加密端口:995:非加密端口:110) SMTP服务器地址:smtp.aliyun.com( ...