CF1863A.Channel

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Petya is an administrator of a channel in one of the messengers. A total of nn people are subscribed to his channel, and Petya is not considered a subscriber.

Petya has published a new post on the channel. At the moment of the publication, there were aa subscribers online. We assume that every subscriber always reads all posts in the channel if they are online.

After this, Petya starts monitoring the number of subscribers online. He consecutively receives qq notifications of the form "a subscriber went offline" or "a subscriber went online". Petya does not know which exact subscriber goes online or offline. It is guaranteed that such a sequence of notifications could have indeed been received.

Petya wonders if all of his subscribers have read the new post. Help him by determining one of the following:

  • it is impossible that all nn subscribers have read the post;
  • it is possible that all nn subscribers have read the post;
  • it is guaranteed that all nn subscribers have read the post.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t5001 \le t \le 500 ). The description of the test cases follows.

The first line of each test case contains three integers nn , aa , and qq ( 1n1001 \le n \le 100 , 0an0 \le a \le n , 1q1001 \le q \le 100 ) — the number of subscribers of the channel, the initial number of subscribers online, and the number of notifications.

The second line of each test case contains a string of length qq , consisting of characters '+' and '-'. The ii -th of these characters is '+', if the ii -th notification tells that a subscriber goes online, and it is '-' otherwise.

输出格式

For each test case, output a single line: "YES" if all nn subscribers are guaranteed to have read the post, "NO" if it is impossible for all nn subscribers to have read the post, and "MAYBE" otherwise.

输入输出样例

  • 输入#1

    4
    5 5 3
    --+
    5 2 3
    ++-
    5 4 2
    -+
    5 0 7
    ++++-++

    输出#1

    YES
    NO
    MAYBE
    YES

说明/提示

In the first test case, there are 55 out of 55 subscribers online in the very beginning, so they will all read the post no matter what. The answer is "YES".

In the second test case, the number of subscribers online becomes 44 after the first two notifications, next someone goes offline, and thus the fifth subscriber has no chance of reading the post. It is impossible for all the subscribers to read the post, so the answer is "NO".

In the third test case, on the one hand, the same person may have gone offline and online (in this case only 44 out of 55 subscribers have read the post), on the other hand, the last notification may have told that the fifth subscriber has gone online (in this case all subscribers have read the post). We cannot deduce which of the two holds, so the answer is "MAYBE".

In the fourth test case, there have to be five subscribers online after all the notifications. All of them will read the post, so the answer is "YES".

首页