309247: CF1650A. Deletions of Two Adjacent Letters
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Deletions of Two Adjacent Letters
题意翻译
给定一个字符串 $s$ ,长度为奇数,由小写字母构成。 只要字符串长度大于1,可以对其进行如下操作:选择字符串中任意两个相邻的字母,并从字符串中删除它们。 例如,在字符串 `lemma` 的一次操作中,你可以能会获得以下四个字符串中的任何一个: `mma`、`lma`、 `lea` 或 `lem`。 特别地,在一次操作中,字符串的长度会减少 $2$。 对于一个字符串 $s$, $s = s_1s_2\ldots s_n$ ( $n>1$ )。你可以在其中任意选择一个下标 $i$ ( $1 \le i \le n$ ) 并更新 $s = s_1 s_2 \ldots s_{i - 1} s_{i + 2} \ldots s_n$ 。 对于给定的 $s$ 和字符 $c$,是否存在一个操作序列可以让 $s$ 在经过若干次操作过后,只剩下的字符为 $c$? 如果可以,输出 `YES`,否则输出 `NO`。 ### 提示: 在第一个测试样例中,$s = abcde$。 - 对于第一次操作,删除前两个字母,我们得到 $s = cde$。 - 在第二次操作中,我们删除最后两个字母,得到 $s = c$题目描述
The string $ s $ is given, the string length is odd number. The string consists of lowercase letters of the Latin alphabet. As long as the string length is greater than $ 1 $ , the following operation can be performed on it: select any two adjacent letters in the string $ s $ and delete them from the string. For example, from the string "lemma" in one operation, you can get any of the four strings: "mma", "lma", "lea" or "lem" In particular, in one operation, the length of the string reduces by $ 2 $ . Formally, let the string $ s $ have the form $ s=s_1s_2 \dots s_n $ ( $ n>1 $ ). During one operation, you choose an arbitrary index $ i $ ( $ 1 \le i < n $ ) and replace $ s=s_1s_2 \dots s_{i-1}s_{i+2} \dots s_n $ . For the given string $ s $ and the letter $ c $ , determine whether it is possible to make such a sequence of operations that in the end the equality $ s=c $ will be true? In other words, is there such a sequence of operations that the process will end with a string of length $ 1 $ , which consists of the letter $ c $ ?输入输出格式
输入格式
The first line of input data contains an integer $ t $ ( $ 1 \le t \le 10^3 $ ) — the number of input test cases. The descriptions of the $ t $ cases follow. Each test case is represented by two lines: - string $ s $ , which has an odd length from $ 1 $ to $ 49 $ inclusive and consists of lowercase letters of the Latin alphabet; - is a string containing one letter $ c $ , where $ c $ is a lowercase letter of the Latin alphabet.
输出格式
For each test case in a separate line output: - YES, if the string $ s $ can be converted so that $ s=c $ is true; - NO otherwise. You can output YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive response).
输入输出样例
输入样例 #1
5
abcde
c
abcde
b
x
y
aaaaaaaaaaaaaaa
a
contest
t
输出样例 #1
YES
NO
NO
YES
YES