#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4001;
set <int> dd[MAXN];
set <int> pp[MAXN];
int main () {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
dd[i].insert(i); pp[i].insert(i);
}
for (int i = 1; i <= n + k - 1; i++) {
char c;
cin >> c;
if (c == 'S') {
int a, b;
cin >> a >> b;
for (auto j : dd[b]) dd[a].insert(j);
for (auto j : dd[a]) dd[b].insert(j);
for (auto j : dd[b]) pp[j].insert(b);
for (auto j : dd[a]) pp[j].insert(a);
} else if (c == 'Q') {
int x, y;
cin >> x >> y;
cout << (dd[x].count(y) ? "yes\n" : "no\n");
} else {
int x;
cin >> x;
cout << pp[x].size() << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
1104 KB |
Output is correct |
2 |
Correct |
204 ms |
3668 KB |
Output is correct |
3 |
Correct |
837 ms |
94856 KB |
Output is correct |
4 |
Correct |
193 ms |
3156 KB |
Output is correct |
5 |
Correct |
194 ms |
2800 KB |
Output is correct |
6 |
Execution timed out |
3532 ms |
387724 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
1104 KB |
Output is correct |
2 |
Correct |
204 ms |
3668 KB |
Output is correct |
3 |
Correct |
837 ms |
94856 KB |
Output is correct |
4 |
Correct |
193 ms |
3156 KB |
Output is correct |
5 |
Correct |
194 ms |
2800 KB |
Output is correct |
6 |
Execution timed out |
3532 ms |
387724 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
184 ms |
1084 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1880 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
184 ms |
1084 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1880 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
1136 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
1136 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
1364 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
1364 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1880 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1880 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
944 KB |
Output is correct |
2 |
Correct |
220 ms |
3664 KB |
Output is correct |
3 |
Correct |
867 ms |
94776 KB |
Output is correct |
4 |
Correct |
188 ms |
3152 KB |
Output is correct |
5 |
Correct |
198 ms |
3004 KB |
Output is correct |
6 |
Execution timed out |
3548 ms |
382348 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
944 KB |
Output is correct |
2 |
Correct |
220 ms |
3664 KB |
Output is correct |
3 |
Correct |
867 ms |
94776 KB |
Output is correct |
4 |
Correct |
188 ms |
3152 KB |
Output is correct |
5 |
Correct |
198 ms |
3004 KB |
Output is correct |
6 |
Execution timed out |
3548 ms |
382348 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |