I love AAAB solution codeforces
Let’s call a string good if its length is at least and all of its characters are except for the last character which is . The good strings are . Note that is not a good string.
You are given an initially empty string.
You can perform the following operation any number of times:
- Choose any position of and insert some good string in that position.
Given a string, can we turn into after some number of operations?
Each test contains multiple test cases. The first line contains a single integer( ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single string( ).
It is guaranteed thatconsists of only the characters and .
It is guaranteed that the sum ofover all test cases does not exceed .
For each test case, print “YES” (without quotes) if we can turn into after some number of operations, and “NO” (without quotes) otherwise.
You can output “YES” and “NO” in any case (for example, strings “yEs“, “yes” and “Yes” will be recognized as a positive response).
4 AABAB ABB AAAAAAAAB A
YES NO YES NO
In the first test case, we transformas such: .
In the third test case, we transformas such: .
In the second and fourth test case, it can be shown that it is impossible to turninto .
I am the Founder and the creator of the blog neoideasblog.com where we share latest trivia questions and answers on a daily basis.