309894: CF1754A. Technical Support

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Technical Support

题意翻译

### 题面翻译 给定一个只包含大写字母 $\texttt{Q}$ 和 $\texttt{A}$ 的字符串,如果字符串里的每一个 $\texttt{Q}$ 都能与**在其之后**的 $\texttt{A}$ 一一对应地匹配,则输出字符串 $\texttt{Yes}$,否则输出字符串 $\texttt{No}$。注意,可以有 $\texttt{A}$ 没有被匹配,但每个 $\texttt{Q}$ 必须成功地匹配。 ### 输入格式 输入一个只包含大写字母 $\texttt{Q}$ 和 $\texttt{A}$ 的字符串。 ### 输出格式 输出字符串 $\texttt{Yes}$ 或 $\texttt{No}$。

题目描述

You work in the quality control department of technical support for a large company. Your job is to make sure all client issues have been resolved. Today you need to check a copy of a dialog between a client and a technical support manager. According to the rules of work, each message of the client must be followed by one or several messages, which are the answer of a support manager. However, sometimes clients ask questions so quickly that some of the manager's answers to old questions appear after the client has asked some new questions. Due to the privacy policy, the full text of messages is not available to you, only the order of messages is visible, as well as the type of each message: a customer question or a response from the technical support manager. It is guaranteed that the dialog begins with the question of the client. You have to determine, if this dialog may correspond to the rules of work described above, or the rules are certainly breached.

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 500 $ ). Description of the test cases follows. The first line of each test case contains one integer $ n $ ( $ 1 \le n \le 100 $ ) — the total number of messages in the dialog. The second line of each test case consists of $ n $ characters "Q" and "A", describing types of messages in the dialog in chronological order. Character "Q" denotes the message with client question, and character "A" — the message with technical support manager answer. It is guaranteed that the first character in the line equals to "Q".

输出格式


For each test case print "Yes" (without quotes) if dialog may correspond to the rules of work, or "No" (without quotes) otherwise.

输入输出样例

输入样例 #1

5
4
QQAA
4
QQAQ
3
QAA
1
Q
14
QAQQAQAAQQQAAA

输出样例 #1

Yes
No
Yes
No
Yes

说明

In the first test case the two questions from the client are followed with two specialist's answers. So this dialog may correspond to the rules of work. In the second test case one of the first two questions was not answered. In the third test case the technical support manager sent two messaged as the answer to the only message of the client.

Input

题意翻译

### 题面翻译 给定一个只包含大写字母 $\texttt{Q}$ 和 $\texttt{A}$ 的字符串,如果字符串里的每一个 $\texttt{Q}$ 都能与**在其之后**的 $\texttt{A}$ 一一对应地匹配,则输出字符串 $\texttt{Yes}$,否则输出字符串 $\texttt{No}$。注意,可以有 $\texttt{A}$ 没有被匹配,但每个 $\texttt{Q}$ 必须成功地匹配。 ### 输入格式 输入一个只包含大写字母 $\texttt{Q}$ 和 $\texttt{A}$ 的字符串。 ### 输出格式 输出字符串 $\texttt{Yes}$ 或 $\texttt{No}$。

Output

题目大意:给定一个只包含大写字母 'Q' 和 'A' 的字符串,如果字符串中的每一个 'Q' 都能与在其之后的 'A' 一一对应地匹配,则输出字符串 'Yes',否则输出字符串 'No'。每个 'Q' 必须成功匹配,但可以有 'A' 没有被匹配。

输入格式:输入一个只包含大写字母 'Q' 和 'A' 的字符串。

输出格式:输出字符串 'Yes' 或 'No'。

输入输出样例:

输入样例 #1:
```
5
4
QQAA
4
QQAQ
3
QAA
1
Q
14
QAQQAQAAQQQAAA
```

输出样例 #1:
```
Yes
No
Yes
No
Yes
```

说明:在第一个测试案例中,客户的两个问题都得到了技术支持经理的回答。第二个测试案例中,前两个问题中的一个没有得到回答。第三个测试案例中,技术支持经理对客户的唯一消息给出了两个回答。题目大意:给定一个只包含大写字母 'Q' 和 'A' 的字符串,如果字符串中的每一个 'Q' 都能与在其之后的 'A' 一一对应地匹配,则输出字符串 'Yes',否则输出字符串 'No'。每个 'Q' 必须成功匹配,但可以有 'A' 没有被匹配。 输入格式:输入一个只包含大写字母 'Q' 和 'A' 的字符串。 输出格式:输出字符串 'Yes' 或 'No'。 输入输出样例: 输入样例 #1: ``` 5 4 QQAA 4 QQAQ 3 QAA 1 Q 14 QAQQAQAAQQQAAA ``` 输出样例 #1: ``` Yes No Yes No Yes ``` 说明:在第一个测试案例中,客户的两个问题都得到了技术支持经理的回答。第二个测试案例中,前两个问题中的一个没有得到回答。第三个测试案例中,技术支持经理对客户的唯一消息给出了两个回答。

加入题单

上一题 下一题 算法标签: