309389: CF1672B. I love AAAB
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
I love AAAB
题意翻译
我们将除了最后一个字符是 $\texttt{B}$ 其余字符都是 $\texttt{A}$ 叫做「好的字符串」,如 $\texttt{AB}$、$\texttt{AAB}$、$\texttt{AAAB}$ 等都是「好的字符串」($\texttt{B}$ 不是「好的字符串」)。判断一个字符串是否能分割成几个「好的字符串」,能输出 $\texttt{YES}$, 不能输出 $\texttt{NO}$。题目描述
Let's call a string good if its length is at least $ 2 $ and all of its characters are $ \texttt{A} $ except for the last character which is $ \texttt{B} $ . The good strings are $ \texttt{AB},\texttt{AAB},\texttt{AAAB},\ldots $ . Note that $ \texttt{B} $ is not a good string. You are given an initially empty string $ s_1 $ . You can perform the following operation any number of times: - Choose any position of $ s_1 $ and insert some good string in that position. Given a string $ s_2 $ , can we turn $ s_1 $ into $ s_2 $ after some number of operations?输入输出格式
输入格式
Each test contains multiple test cases. The first line contains a single integer $ t $ ( $ 1 \leq t \leq 10^4 $ ) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single string $ s_2 $ ( $ 1 \leq |s_2| \leq 2 \cdot 10^5 $ ). It is guaranteed that $ s_2 $ consists of only the characters $ \texttt{A} $ and $ \texttt{B} $ . It is guaranteed that the sum of $ |s_2| $ over all test cases does not exceed $ 2 \cdot 10^5 $ .
输出格式
For each test case, print "YES" (without quotes) if we can turn $ s_1 $ into $ s_2 $ 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).
输入输出样例
输入样例 #1
4
AABAB
ABB
AAAAAAAAB
A
输出样例 #1
YES
NO
YES
NO