CF1650A.Deletions of Two Adjacent Letters

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The string ss 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 11 , the following operation can be performed on it: select any two adjacent letters in the string ss 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 22 .

Formally, let the string ss have the form s=s1s2sns=s_1s_2 \dots s_n ( n>1n>1 ). During one operation, you choose an arbitrary index ii ( 1i<n1 \le i < n ) and replace s=s1s2si1si+2sns=s_1s_2 \dots s_{i-1}s_{i+2} \dots s_n .

For the given string ss and the letter cc , determine whether it is possible to make such a sequence of operations that in the end the equality s=cs=c will be true? In other words, is there such a sequence of operations that the process will end with a string of length 11 , which consists of the letter cc ?

输入格式

The first line of input data contains an integer tt ( 1t1031 \le t \le 10^3 ) — the number of input test cases.

The descriptions of the tt cases follow. Each test case is represented by two lines:

  • string ss , which has an odd length from 11 to 4949 inclusive and consists of lowercase letters of the Latin alphabet;
  • is a string containing one letter cc , where cc is a lowercase letter of the Latin alphabet.

输出格式

For each test case in a separate line output:

  • YES, if the string ss can be converted so that s=cs=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

说明/提示

In the first test case, ss ="abcde". You need to get ss ="c". For the first operation, delete the first two letters, we get ss ="cde". In the second operation, we delete the last two letters, so we get the expected value of ss ="c".

In the third test case, ss ="x", it is required to get ss ="y". Obviously, this cannot be done.

首页