#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int N, Q;
map<int, int> charges;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> N >> Q;
for (int i = 0; i < Q; i++){
string T = "";
int A = 0;
int B = 0;
cin >> T >> A >> B;
if (T == "A"){
if (charges[A] == 0 && charges[B] == 0){
charges[A] = 1;
charges[B] = -1;
}
else if (charges[A] == 1){
charges[B] = -1;
}
else if (charges[A] == -1){
charges[B] = 1;
}
else if (charges[B] == -1){
charges[A] = 1;
}
else if (charges[B] == 1){
charges[A] = -1;
}
}
else if (T == "R"){
if (charges[A] == 0 && charges[B] == 0){
charges[A] = 1;
charges[B] = 1;
}
else if (charges[A] == 1){
charges[B] = 1;
}
else if (charges[A] == -1){
charges[B] = -1;
}
else if (charges[B] == -1){
charges[A] = -1;
}
else if (charges[B] == 1){
charges[A] = 1;
}
}
else if (T == "Q"){
if (charges[A] == 0 || charges[B] == 0){
cout << "?" << endl;
}
else if (charges[A] == charges[B]){
cout << "R" << endl;
}
else if ((charges[A] != 0) && (charges[B] != 0) && (charges[A] != charges[B])){
cout << "A" << endl;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
3868 KB |
Output is correct |
2 |
Correct |
57 ms |
4024 KB |
Output is correct |
3 |
Correct |
57 ms |
3456 KB |
Output is correct |
4 |
Correct |
57 ms |
4032 KB |
Output is correct |
5 |
Correct |
53 ms |
4208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
4372 KB |
Output is correct |
2 |
Correct |
77 ms |
3816 KB |
Output is correct |
3 |
Incorrect |
91 ms |
4864 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
4284 KB |
Output is correct |
2 |
Correct |
85 ms |
3780 KB |
Output is correct |
3 |
Incorrect |
94 ms |
4464 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
51 ms |
3868 KB |
Output is correct |
7 |
Correct |
57 ms |
4024 KB |
Output is correct |
8 |
Correct |
57 ms |
3456 KB |
Output is correct |
9 |
Correct |
57 ms |
4032 KB |
Output is correct |
10 |
Correct |
53 ms |
4208 KB |
Output is correct |
11 |
Correct |
62 ms |
4372 KB |
Output is correct |
12 |
Correct |
77 ms |
3816 KB |
Output is correct |
13 |
Incorrect |
91 ms |
4864 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |