#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
const int N = 5e4;
int n, k;
bitset<N> bt[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> k;
for (int i = 0; i < n; i++) {
bt[i][i] = 1;
}
for (int i = 0; i < n+k-1; i++) {
char tp;
cin >> tp;
if (tp == 'S') {
int x, y;
cin >> x >> y;
x--; y--;
// bt[x] = bt[y] = (bt[x] | bt[y]);
bt[x] |= bt[y];
bt[y] |= bt[x];
}
else if (tp == 'Q') {
int x, z;
cin >> x >> z;
x--; z--;
if (bt[x][z]) cout << "yes\n";
else cout << "no\n";
}
else {
int z;
cin >> z;
z--;
int ans = 0;
for (int i = 0; i < n; i++) {
if (bt[i][z]) ans++;
}
cout << ans << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Correct |
26 ms |
25432 KB |
Output is correct |
3 |
Correct |
26 ms |
25436 KB |
Output is correct |
4 |
Correct |
27 ms |
25432 KB |
Output is correct |
5 |
Correct |
27 ms |
25424 KB |
Output is correct |
6 |
Correct |
27 ms |
25432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Correct |
26 ms |
25432 KB |
Output is correct |
3 |
Correct |
26 ms |
25436 KB |
Output is correct |
4 |
Correct |
27 ms |
25432 KB |
Output is correct |
5 |
Correct |
27 ms |
25424 KB |
Output is correct |
6 |
Correct |
27 ms |
25432 KB |
Output is correct |
7 |
Correct |
16 ms |
2904 KB |
Output is correct |
8 |
Correct |
188 ms |
25424 KB |
Output is correct |
9 |
Correct |
197 ms |
25444 KB |
Output is correct |
10 |
Correct |
193 ms |
25344 KB |
Output is correct |
11 |
Correct |
192 ms |
25716 KB |
Output is correct |
12 |
Correct |
177 ms |
25680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2457 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2457 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2553 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2553 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2546 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2546 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2560 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2904 KB |
Output is correct |
2 |
Runtime error |
2560 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Correct |
29 ms |
25432 KB |
Output is correct |
3 |
Correct |
26 ms |
25432 KB |
Output is correct |
4 |
Correct |
26 ms |
25432 KB |
Output is correct |
5 |
Correct |
25 ms |
25432 KB |
Output is correct |
6 |
Correct |
25 ms |
25448 KB |
Output is correct |
7 |
Correct |
15 ms |
2904 KB |
Output is correct |
8 |
Runtime error |
2398 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2904 KB |
Output is correct |
2 |
Correct |
29 ms |
25432 KB |
Output is correct |
3 |
Correct |
26 ms |
25432 KB |
Output is correct |
4 |
Correct |
26 ms |
25432 KB |
Output is correct |
5 |
Correct |
25 ms |
25432 KB |
Output is correct |
6 |
Correct |
25 ms |
25448 KB |
Output is correct |
7 |
Correct |
15 ms |
2904 KB |
Output is correct |
8 |
Runtime error |
2398 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |