-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Secret_Sport.cpp
49 lines (40 loc) · 991 Bytes
/
A_Secret_Sport.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
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
int a_wins = 0, b_wins = 0;
int x = 0, y = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'A') {
a_wins++;
} else {
b_wins++;
}
if (a_wins >= x && a_wins > b_wins) {
x = a_wins;
} else if (b_wins >= y && b_wins > a_wins) {
y = b_wins;
}
}
if (x > y) {
cout << "A\n";
} else if (y > x) {
cout << "B\n";
} else {
if (a_wins > b_wins) {
cout << "A\n";
} else if (b_wins > a_wins) {
cout << "B\n";
} else {
cout << "?\n";
}
}
}
return 0;
}