CF1671A.String Building
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string s. You have to determine whether it is possible to build the string s out of strings aa, aaa, bb and/or bbb by concatenating them. You can use the strings aa, aaa, bb and/or bbb any number of times and in any order.
For example:
- aaaabbb can be built as aa + aa + bbb;
- bbaaaaabbb can be built as bb + aaa + aa + bbb;
- aaaaaa can be built as aa + aa + aa;
- abab cannot be built from aa, aaa, bb and/or bbb.
给你一个字符串 s。你需要判断是否可以通过拼接字符串 aa、aaa、bb 和/或 bbb 来构造出字符串 s。你可以以任意顺序、任意次数使用这些字符串 aa、aaa、bb 和/或 bbb。
例如:
aaaabbb可以构造为aa+aa+bbb;bbaaaaabbb可以构造为bb+aaa+aa+bbb;aaaaaa可以构造为aa+aa+aa;abab无法由aa、aaa、bb和/或bbb构造出来。
输入格式
The first line contains one integer t (1≤t≤1000) — the number of test cases.
Each test case consists of one line containing the string s (1≤∣s∣≤50), consisting of characters a and/or b.
第一行包含一个整数 t(1≤t≤1000)—— 表示测试用例的数量。
每个测试用例由一行组成,该行包含字符串 s(1≤∣s∣≤50),其字符仅由 a 和/或 b 构成。
输出格式
For each test case, print YES if it is possible to build the string s. Otherwise, print NO.
You may print each letter in any case (for example, YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).
对于每个测试用例,如果可以构造字符串 s,则输出 YES;否则输出 NO。
您可以以任意大小写形式输出每个字母(例如,YES、yes、Yes 均被视为肯定回答;NO、no 和 nO 均被视为否定回答)。
输入输出样例
输入#1
8 aaaabbb bbaaaaabbb aaaaaa abab a b aaaab bbaaa
输出#1
YES YES YES NO NO NO NO YES
说明/提示
The first four test cases of the example are described in the statement.
示例的前四个测试用例在题目描述中已给出。
输入解题思路,AI测评打分。不知道怎么写?