B. Email from Polycarp

time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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

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.

Examples
input

Copy
4
hello
hello
hello
helloo
hello
hlllloo
hello
helo
output

Copy
YES
YES
NO
NO
input

Copy
5
aa
bb
codeforces
codeforce
polycarp
poolycarpp
aaaa
aaaab
abcdefghijklmnopqrstuvwxyz
zabcdefghijklmnopqrstuvwxyz
output

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

  1. Codeforces Round #568 (Div. 2) B. Email from Polycarp

    链接: https://codeforces.com/contest/1185/problem/B 题意: Methodius received an email from his friend Po ...

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

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

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

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

  4. 暑期ACM集训

    2019-07-17 08:42:11 这是总结昨天的做题情况 总体来说,好久的没做题了,实力下降了许多,这一个月假又学习吧!!!! A - Ropewalkers Polycarp decided ...

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

  6. codeforces 589A Email Aliases(map)

    Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect t ...

  7. TTTTTTTTTTTTTTTTTT CodeForces 589A Email Aliases 字符串 map

    A - Email Aliases Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u ...

  8. 如何在网页中提取Email地址

    开博好久了,今天第一次发表技术文档,之前总是将一些好的事例保存在电脑,时间久了找起来也很麻烦,所以还是放在博客里进行归类比较方便,这样也能将自己在学习过程中的一些心得体会分享给大家,也能给需要的人一点 ...

  9. 系统中没有邮件客户端设置autoLink=email会挂掉的问题

    TextView的autoLink属性为我们提供了很大的便利性,当文本中有网址,邮箱或电话的时候可以让我们方便地执行打电话发邮件等动作,不过也有一些问题,比如说设置autoLink包含email属性, ...

随机推荐

  1. 怎么HTML表格中的所有字体居中?

    一开始,我在table标签里加入align="center"  发现没什么用.... 后来在css里加入,就可以了 成果如图:

  2. 中山Day4——普及

    生活开始日益平淡了呢...今天130分. 收获:归并排序求逆序对 背包问题(01.完全.多重)(外带滚动数组优化) T1:题目链接(才不会告诉你们下面的代码也是洛谷上弄来的) 思路:动态规划.首先,设 ...

  3. redis之Set(无序)类型常用方法总结

    redis之Set(无序)类型常用方法总结 存--sadd key member [member ...] 取--SMEMBERS key sadd key member [member ...] 向 ...

  4. #写一个随机产生138开头手机号的程序 1.输入一个数量,产生xx条手机号 2.产生的这些手机号不能重复

    import randomcount=int(input('请输入你所想要手机号数量:'))prefix='138'for i in range(count): num=random.sample(r ...

  5. jQuery序列化表单 serialize() serializeArray()(非常重要)

    https://m.2cto.com/kf/201412/361303.html 2014-12-15 1.serialize()方法 描述:序列化表单内容为字符串,用于Ajax请求. 格式:var ...

  6. java虚拟机之垃圾回收机制

    一.需要回收的内存区域     程序计数器.虚拟机栈.本地方法栈 3 个区域随线程生灭(因为是线程私有),栈中的栈帧随着方法的进入和退出而有条不紊地执行着出栈和入栈操作.而 Java 堆和方法区则不一 ...

  7. English-Names

    English-Names 1. 西方姓名的组成 2. 职业姓氏 3. 更多相关链接 中国的姓名,姓氏在前,名子在后.传统也有中间字(世代字).名子非常多.所谓百家姓,姓氏数量有限,约500个左右. ...

  8. tomcat重载web项目,debug

    Reloading Context with name [/testCookie] is completed 加载上下文名称[ / ]完成testcookie //start九月 05, 2017 9 ...

  9. mysql#自定义序列

    原文 mysql主键不用自增数字的时候,可以参考如下方式,我抄来的. -- 创建公共的序列表 DROP TABLE IF EXISTS t_common_sequence; CREATE TABLE ...

  10. SpringBoot整合MyBatis获得插入数据后获取主键,返回值总是1

    xml里的写法 <insert id="insertLogin" parameterType="com.xyt.p2p.pojo.LoginInfo" k ...