CF1754A.Technical Support

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 tt (1≤t≤5001 \le t \le 500). Description of the test cases follows.

The first line of each test case contains one integer nn (1≤n≤1001 \le n \le 100) — the total number of messages in the dialog.

The second line of each test case consists of nn 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".

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤5001 \le t \le 500)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)—— 表示对话中消息的总数量。

每个测试用例的第二行包含 nn 个字符,每个字符为 "Q" 或 "A",按时间顺序描述对话中各消息的类型。字符 "Q" 表示客户提出的问题,字符 "A" 表示技术支持经理的回复。保证该行的第一个字符为 "Q"。

输出格式

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

对于每个测试用例,如果该对话可能符合工作规则,则输出“Yes”(不带引号);否则输出“No”(不带引号)。

输入输出样例

  • 输入#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.

在第一个测试用例中,客户提出的两个问题均得到了专家的回复。因此,该对话可能符合工作规范。

在第二个测试用例中,前两个问题中的一个未被答复。

在第三个测试用例中,技术支持经理针对客户唯一的一条消息发送了两条回复。

输入解题思路,AI测评打分。不知道怎么写?

首页