#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;
}
}
*/
if (T == "R"){
if (charges[A] == 0 && charges[B] == 0){
charges[A] = B;
charges[B] = A;
}
else if (charges[A] != 0){
charges[charges[B]] = charges[A];
charges[B] = charges[A];
charges[charges[A]] = charges[A];
}
else if (charges[B] != 0){
charges[charges[A]] = charges[B];
charges[A] = charges[B];
charges[charges[B]] = charges[B];
}
}
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] == -charges[B]){
cout << "A" << endl;
}
else{
cout << "?" << endl;
}
}
}
//cout << "----------------" << endl;
//for (int i = 1; i <= N; i++){
//cout << charges[i] << endl;
//}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
3832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
5704 KB |
Output is correct |
2 |
Correct |
100 ms |
5024 KB |
Output is correct |
3 |
Incorrect |
96 ms |
6196 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
5188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |