链接:

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的更多相关文章

  1. Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)

    题目:http://codeforces.com/contest/1185/problem/G1 题意:给你n给选项,每个选项有个类型和价值,让你选择一个序列,价值和为m,要求连续的不能有两个相同的类 ...

  2. Codeforces Round #568 (Div. 2) G2. Playlist for Polycarp (hard version)

    因为不会打公式,随意就先将就一下? #include<cstdio> #include<algorithm> #include<iostream> #include ...

  3. Codeforces Round #568 (Div. 2)B

    B. Email from Polycarp 题目链接:http://codeforces.com/contest/1185/problem/B 题目: Methodius received an e ...

  4. codeforces Round #568(Div.2)A B C

    有点菜,只写出了三道.活不多说,上题开干. A. Ropewalkers Polycarp decided to relax on his weekend and visited to the per ...

  5. Codeforces Round #568 (Div. 2)A

    A. Ropewalkers 题目链接:http://codeforces.com/contest/1185/problem/A 题目: Polycarp decided to relax on hi ...

  6. Codeforces Round #568 (Div. 2) A.Ropewalkers

    链接: https://codeforces.com/contest/1185/problem/A 题意: Polycarp decided to relax on his weekend and v ...

  7. Codeforces Round #568 (Div. 2) D. Extra Element

    链接: https://codeforces.com/contest/1185/problem/D 题意: A sequence a1,a2,-,ak is called an arithmetic ...

  8. 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 ...

  9. Codeforces Round #568 Div. 2

    没有找到这场div3被改成div2的理由. A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long ...

随机推荐

  1. ISO/ISO 参考模型 和 TCP/IP模型

    OSI 参考模型 国际化标准组织(International Organization for Standardization,ISO)于1978年提出了一个网络体系结构,成为开放系统互联参考模型(O ...

  2. Private Variable

    Any variable defined inside a function is considered private since it is inaccessable outside that f ...

  3. cocos2dx[3.2](9) 新回调函数std::bind

    自从3.0引用了C++11标准后,回调函数采用的新的函数适配器:std::function.std::bind. 而曾经的回调函数menu_selector.callfunc_selector.ccc ...

  4. python学习之模块-模块(四)

    5.9 logging模块 常用参数 logging.basicConfig()函数中可通过具体参数来更改logging模块默认行为,可用参数有: filename:用指定的文件名创建FiledHan ...

  5. ssh端口转发功能

    一.SSH 端口转发能够提供两大功能: 1.加密SSH Client 端至SSH Server 端之间的通讯数据 2.突破防火墙的限制完成一些之前无法建立的TCP 连接  (隧道功能) 二:SSH端口 ...

  6. 【VS开发】利用VS2015的工程文件来复制另外一个工程的配置的使用说明

    [VS开发]利用VS2015的工程文件来复制另外一个工程的配置的使用说明 标签:[VS开发] 说明:总是有时候会遇到这样的问题,在一个工程中完成了对某些PKG包的包含,包括头文件和库等都能发现,但是我 ...

  7. python 并发编程 io模型 目录

    python 并发编程 IO模型介绍 python 并发编程 socket 服务端 客户端 阻塞io行为 python 并发编程 阻塞IO模型 python 并发编程 非阻塞IO模型 python 并 ...

  8. etcd单节点数据备份与恢复

    插入测试数据 # etcdctl put smith # etcdctl put allen # etcdctl put ward # etcdctl put jones # etcdctl put ...

  9. XOR on segment(线段树区间异或更新)

    原题传送门 本题大意:给定n个数字和m个操作,操作共有两种,第一种是求解区间l到r上元素的和,第二种是将区间l到r的元素都异或一个x,作为某个位置的新值. 很容易想到线段树维护区间和,但是我们发现,在 ...

  10. Spring整合jms消息

    整个项目目录结构如下: JmsSpringContext.java package com.wulj.jms.internal.activisor; import org.slf4j.Logger; ...