#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] == 0){
charges[B] = 1;
}
else if (charges[A] == -1 && charges[B] == 0){
charges[B] = -1;
}
else if (charges[B] == -1 && charges[A] == 0){
charges[A] = -1;
}
else if (charges[B] == 1 && charges[A] == 0){
charges[A] = 1;
}
}
else if (T == "Q"){
if (charges[A] != -1 || charges[A] != 1 || charges[B] != -1 || charges[B] != 1){
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 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
3772 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
4232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
77 ms |
4092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |