欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1650A.Deletions of Two Adjacent Letters
Deletions of Two Adjacent Letters
The string 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 , the following operation can be performed on it: select any two adjacent letters in the string 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 .
Formally, let the string have the form (). During one operation, you choose an arbitrary index () and replace .
For the given string and the letter , determine whether it is possible to make such a sequence of operations that in the end the equality will be true? In other words, is there such a sequence of operations that the process will end with a string of length , which consists of the letter ?
Input
The first line of input data contains an integer () — the number of input test cases.
The descriptions of the cases follow. Each test case is represented by two lines:
- string , which has an odd length from to inclusive and consists of lowercase letters of the Latin alphabet;
- is a string containing one letter , where is a lowercase letter of the Latin alphabet.
Output
For each test case in a separate line output:
YES, if the string can be converted so that is true;NOotherwise.
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).
Note
In the first test case, ="abcde". You need to get ="c". For the first operation, delete the first two letters, we get ="cde". In the second operation, we delete the last two letters, so we get the expected value of ="c".
In the third test case, ="x", it is required to get ="y". Obviously, this cannot be done.
Samples
5
abcde
c
abcde
b
x
y
aaaaaaaaaaaaaaa
a
contest
t
YES
NO
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |