CF1185B.Email from Polycarp

普及-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

米修斯收到了朋友波利卡普发来的一封电子邮件。然而,波利卡普的键盘坏了,因此按一次某个键,可能会导致对应字符在屏幕上重复出现多次(而在正常键盘上,按一次键只会输出一个字符)。

例如,当输入单词 "hello" 时,以下单词可能是实际输出结果:"hello"、"hhhhello"、"hheeeellllooo";但以下单词不可能是输出结果:"hell"、"helo"、"hhllllooo"。

注意:每次按键时,对应的字符必须至少出现一次(可能多次)。键盘的损坏是随机的,这意味着即使按同一个键,也可能得到不同数量的字符。

对于邮件中的每个单词,米修斯都猜测了波利卡普本想输入的原始单词,但他并不确定自己的猜测是否正确,因此请你帮忙验证。

你将收到若干组单词对。对每组单词对,请判断:第二个单词是否可能是通过在波利卡普的坏键盘上输入第一个单词而得到的。

输入格式

The first line of the input contains one integer nn (1≤n≤1051 \le n \le 10^5) — 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 10610^6.

It is guaranteed that the total length of all words ss in the input is not greater than 10610^6. Also, it is guaranteed that the total length of all words tt in the input is not greater than 10610^6.

输入的第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5)—— 表示需要检查的字符串对的数量。随后的输入包含 nn 个字符串对的描述。

每个描述的第一行包含一个非空单词 ss,由小写拉丁字母组成;第二行包含一个非空单词 tt,同样由小写拉丁字母组成。两个字符串的长度均不超过 10610^6。

保证输入中所有单词 ss 的总长度不超过 10610^6,且所有单词 tt 的总长度也不超过 10610^6。

输出格式

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.

输出 nn 行。对于第 ii 对单词 ss 和 tt,在第 ii 行中,若单词 tt 可通过输入单词 ss 得到,则输出 YES;否则输出 NO。

输入输出样例

  • 输入#1

    4
    hello
    hello
    hello
    helloo
    hello
    hlllloo
    hello
    helo

    输出#1

    YES
    YES
    NO
    NO
  • 输入#2

    5
    aa
    bb
    codeforces
    codeforce
    polycarp
    poolycarpp
    aaaa
    aaaab
    abcdefghijklmnopqrstuvwxyz
    zabcdefghijklmnopqrstuvwxyz

    输出#2

    NO
    NO
    YES
    NO
    NO

输入解题思路,AI测评打分。不知道怎么写?

首页