#include <bits/stdc++.h>
using namespace std;
//ana batfeshe55
const int MAXN = 120025;
int arr[MAXN]; int cnt = 0;
bool vis[MAXN];
int main () {
int n, k;
cin >> n >> k;
vis[1] = 1;
for (int i = 1; i <= n + k - 1; i++) {
char c;
cin >> c;
if (c == 'S') {
int x, y;
cin >> x >> y;
if (x > y) swap(x, y);
arr[y] = cnt++; vis[y] = 1;
} else if (c == 'Q') {
int x, y;
cin >> x >> y;
if (x == y) {
cout << "yes\n";
continue;
}
if (!vis[y] || !vis[x]) {
cout << "no\n";
continue;
}
if (x == 1 || y == 1) {
cout << "yes\n";
continue;
}
if (arr[y] < arr[x]) {
cout << "yes\n";
} else {
cout << "no\n";
}
} else {
int x;
cin >> x;
if (!vis[x]) {
cout << 1 << '\n';
continue;
}
if (x == 1) {
cout << cnt + 1 << '\n';
continue;
}
cout << arr[x] + 2 << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
604 KB |
Output is correct |
2 |
Correct |
230 ms |
1208 KB |
Output is correct |
3 |
Correct |
228 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
604 KB |
Output is correct |
2 |
Correct |
230 ms |
1208 KB |
Output is correct |
3 |
Correct |
228 ms |
1364 KB |
Output is correct |
4 |
Incorrect |
204 ms |
780 KB |
Extra information in the output file |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
177 ms |
812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
177 ms |
812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
193 ms |
648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
193 ms |
648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
176 ms |
872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
176 ms |
872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
194 ms |
780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
194 ms |
780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |