#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1.2e5;
bitset<MAX_N + 1> d[MAX_N + 1];
int main() {
int n, q;
cin >> n >> q;
for ( int i = 1; i <= n; i++ )
d[i][i] = true;
q += n - 1;
while ( q-- ) {
char t;
cin >> t;
if ( t == 'S' ) {
int a, b;
cin >> a >> b;
d[a] |= d[b];
d[b] |= d[a];
} else if ( t == 'Q' ) {
int a, b;
cin >> a >> b;
cout << (d[a][b] ? "yes" : "no") << "\n";
} else if ( t == 'C' ) {
int a;
cin >> a;
cout << 0 << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
3668 KB |
Output is correct |
2 |
Correct |
221 ms |
61792 KB |
Output is correct |
3 |
Correct |
202 ms |
61776 KB |
Output is correct |
4 |
Correct |
212 ms |
61812 KB |
Output is correct |
5 |
Correct |
214 ms |
61832 KB |
Output is correct |
6 |
Correct |
206 ms |
61748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
3668 KB |
Output is correct |
2 |
Correct |
221 ms |
61792 KB |
Output is correct |
3 |
Correct |
202 ms |
61776 KB |
Output is correct |
4 |
Correct |
212 ms |
61812 KB |
Output is correct |
5 |
Correct |
214 ms |
61832 KB |
Output is correct |
6 |
Correct |
206 ms |
61748 KB |
Output is correct |
7 |
Incorrect |
183 ms |
3636 KB |
Extra information in the output file |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
3756 KB |
Output is correct |
2 |
Runtime error |
285 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
3756 KB |
Output is correct |
2 |
Runtime error |
285 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
3772 KB |
Output is correct |
2 |
Runtime error |
169 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
3772 KB |
Output is correct |
2 |
Runtime error |
169 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
190 ms |
4004 KB |
Output is correct |
2 |
Runtime error |
156 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
190 ms |
4004 KB |
Output is correct |
2 |
Runtime error |
156 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
3668 KB |
Output is correct |
2 |
Runtime error |
155 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
3668 KB |
Output is correct |
2 |
Runtime error |
155 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
3696 KB |
Output is correct |
2 |
Correct |
209 ms |
61780 KB |
Output is correct |
3 |
Correct |
209 ms |
62032 KB |
Output is correct |
4 |
Correct |
215 ms |
61780 KB |
Output is correct |
5 |
Correct |
206 ms |
61836 KB |
Output is correct |
6 |
Correct |
214 ms |
61784 KB |
Output is correct |
7 |
Correct |
177 ms |
3696 KB |
Output is correct |
8 |
Runtime error |
156 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
3696 KB |
Output is correct |
2 |
Correct |
209 ms |
61780 KB |
Output is correct |
3 |
Correct |
209 ms |
62032 KB |
Output is correct |
4 |
Correct |
215 ms |
61780 KB |
Output is correct |
5 |
Correct |
206 ms |
61836 KB |
Output is correct |
6 |
Correct |
214 ms |
61784 KB |
Output is correct |
7 |
Correct |
177 ms |
3696 KB |
Output is correct |
8 |
Runtime error |
156 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |