-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.cpp
41 lines (36 loc) · 990 Bytes
/
channel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(void) {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n, a, q;
cin >> n >> a >> q;
string notifs;
cin >> notifs;
if (n == a) {
cout << "YES" << endl;
} else {
int aAfter = a;
int count = 0;
bool reachedA = false;
for (int i = 0; i < q; i++) {
if (notifs[i] == '+') {
aAfter++;
} else if (aAfter > 0) {
aAfter--;
}
if (aAfter == a) count++;
}
if (aAfter >= n) {
cout << "YES" << endl;
} else if ((count) == (n - a) || aAfter == a) {
cout << "MAYBE" << endl;
} else {
cout << "NO" << endl;
}
}
}
return 0;
}