B. Email from Polycarp
B. Email from Polycarp
3 seconds
256 megabytes
standard input
standard output
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.
The first line of the input contains one integer nn (1≤n≤1051≤n≤105) — the number of pairs to check. Further input contains nn descriptions of pairs.
The first line of each description contains a single non-empty word ss consisting of lowercase Latin letters. The second line of the description contains a single non-empty word tt consisting of lowercase Latin letters. The lengths of both strings are not greater than 106106.
It is guaranteed that the total length of all words ss in the input is not greater than 106106. Also, it is guaranteed that the total length of all words tt in the input is not greater than 106106.
Output nn lines. In the ii-th line for the ii-th pair of words ss and tt print YES if the word tt could be printed by typing the word ss. Otherwise, print NO.
4
hello
hello
hello
helloo
hello
hlllloo
hello
helo
YES
YES
NO
NO
5
aa
bb
codeforces
codeforce
polycarp
poolycarpp
aaaa
aaaab
abcdefghijklmnopqrstuvwxyz
zabcdefghijklmnopqrstuvwxyz
NO
NO
YES
NO
NO
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
string s1, s2;
int main()
{
int t;
cin >> t;
while (t--)
{
int flag = ;
cin >> s1 >> s2;
int i = , j = ;
if (s1.size() > s2.size())
flag = ;
else
{
for (; s2[j]; j++, i++)
{
if (s1[i] != s2[j])
{
if (i == )
{
flag = ;
break;
}
else
{
if (s2[j] == s2[j - ])
i--;//如果s2有重复的字母,那么s1[i]保持不变,继续比较s[j+1]
else
{
flag = ;
break;
} }
} }
}
if (flag == && i == s1.size())
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return ;
}
B. Email from Polycarp的更多相关文章
- Codeforces Round #568 (Div. 2) B. Email from Polycarp
链接: https://codeforces.com/contest/1185/problem/B 题意: Methodius received an email from his friend Po ...
- 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 ...
- 暑期ACM集训
2019-07-17 08:42:11 这是总结昨天的做题情况 总体来说,好久的没做题了,实力下降了许多,这一个月假又学习吧!!!! A - Ropewalkers Polycarp decided ...
- 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest A Email Aliases(模拟STL vector+map)
Email AliasesCrawling in process... Crawling failed Time Limit:2000MS Memory Limit:524288KB ...
- codeforces 589A Email Aliases(map)
Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect t ...
- TTTTTTTTTTTTTTTTTT CodeForces 589A Email Aliases 字符串 map
A - Email Aliases Time Limit:2000MS Memory Limit:524288KB 64bit IO Format:%I64d & %I64u ...
- 如何在网页中提取Email地址
开博好久了,今天第一次发表技术文档,之前总是将一些好的事例保存在电脑,时间久了找起来也很麻烦,所以还是放在博客里进行归类比较方便,这样也能将自己在学习过程中的一些心得体会分享给大家,也能给需要的人一点 ...
- 系统中没有邮件客户端设置autoLink=email会挂掉的问题
TextView的autoLink属性为我们提供了很大的便利性,当文本中有网址,邮箱或电话的时候可以让我们方便地执行打电话发邮件等动作,不过也有一些问题,比如说设置autoLink包含email属性, ...
随机推荐
- 【转】python创建和删除文件
#!/usr/bin/python #-*-coding:utf-8-*- #指定编码格式,python默认unicode编码 import os directory = "./dir&qu ...
- 关于c++的头文件和变量声明
写再最前面:摘录于柳神的笔记: C++的头⽂件⼀般是没有像C语⾔的 .h 这样的扩展后缀的,⼀般情况下C语⾔⾥⾯的头⽂件去掉 .h 然 后在前⾯加个 c 就可以继续在C++⽂件中使⽤C语⾔头⽂件中 ...
- 34 java 文件过滤 FileFilter
package com.da.tool.util; import org.apache.commons.io.filefilter.RegexFileFilter; import java.io.Fi ...
- Nodejs 开发 随手记
console.log(Object.prototype.toString.call(Now.toString())); //类型判断
- 大数据萌新的Python学习之路(一)
笔记开始简介 从2018年9月份正式进入大学的时代,大数据和人工智能的崛起让我选择了计算机专业学习数据科学与大数据技术专业,接触的第一门语言就是C语言,后来因为同学推荐的原因进入了学校的人工智能研究协 ...
- uniGUI之MainModule(12)
1]必须设置. 一个 user 一个, 在此放数据库控件是各 user 独立 2]常用属性: 应用 MainModule 正确的方法是将连接组件放置在 MainModule 上, 并将数据集放在窗体 ...
- js加密(十一)yhz566 md5
1. http://www.yhz566.com/ 2. 登录加密 3. navigator = {}; var rng_psize = 256; var b64map = "ABCDEFG ...
- C/C++网络编程2——socket函数
本节主要介绍创建套接字的socket函数. #include <sys/socket.h> int socket(int domain, int type, int protocol); ...
- UITextField的使用、介绍、讲解、全解、简介、说明
[2018年中秋节良心写作]文章将尽可能的全面介绍UITextField的所有相关知识,逻辑连贯,需要认真理解,一气呵成. 关键词: 屏幕键盘(onscreen keyboard).键盘自定义.键盘类 ...
- python中对闭包的理解
运行环境声明:本人的代码在sublime text 3中写的,可以Ctrl+b运行.python版本是python3.6.如果您直接运行的,请自觉加入if __name__ == '__main__' ...