A15001 | I love AAAB
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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$ .
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).
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
In the first test case, we transform $s_1$ as such: $\varnothing \to \color{red}{\texttt{AAB}} \to \texttt{A}\color{red}{\texttt{AB}}\texttt{AB}$ .
In the third test case, we transform $s_1$ as such: $\varnothing \to \color{red}{\texttt{AAAAAAAAB}}$ .
In the second and fourth test case, it can be shown that it is impossible to turn $s_1$ into $s_2$ .
In the third test case, we transform $s_1$ as such: $\varnothing \to \color{red}{\texttt{AAAAAAAAB}}$ .
In the second and fourth test case, it can be shown that it is impossible to turn $s_1$ into $s_2$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted