#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 4000;
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 |
177 ms |
1620 KB |
Output is correct |
2 |
Correct |
187 ms |
3924 KB |
Output is correct |
3 |
Correct |
186 ms |
4112 KB |
Output is correct |
4 |
Correct |
187 ms |
4128 KB |
Output is correct |
5 |
Correct |
191 ms |
4088 KB |
Output is correct |
6 |
Correct |
186 ms |
4052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
1620 KB |
Output is correct |
2 |
Correct |
187 ms |
3924 KB |
Output is correct |
3 |
Correct |
186 ms |
4112 KB |
Output is correct |
4 |
Correct |
187 ms |
4128 KB |
Output is correct |
5 |
Correct |
191 ms |
4088 KB |
Output is correct |
6 |
Correct |
186 ms |
4052 KB |
Output is correct |
7 |
Incorrect |
172 ms |
1620 KB |
Extra information in the output file |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
1560 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4444 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
1560 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4444 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
796 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4444 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
796 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4444 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
744 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4552 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
744 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4552 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
732 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4440 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
732 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4440 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
808 KB |
Output is correct |
2 |
Correct |
204 ms |
2516 KB |
Output is correct |
3 |
Correct |
201 ms |
2900 KB |
Output is correct |
4 |
Correct |
189 ms |
2740 KB |
Output is correct |
5 |
Correct |
187 ms |
2604 KB |
Output is correct |
6 |
Correct |
189 ms |
2908 KB |
Output is correct |
7 |
Correct |
173 ms |
812 KB |
Output is correct |
8 |
Runtime error |
4 ms |
4444 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
808 KB |
Output is correct |
2 |
Correct |
204 ms |
2516 KB |
Output is correct |
3 |
Correct |
201 ms |
2900 KB |
Output is correct |
4 |
Correct |
189 ms |
2740 KB |
Output is correct |
5 |
Correct |
187 ms |
2604 KB |
Output is correct |
6 |
Correct |
189 ms |
2908 KB |
Output is correct |
7 |
Correct |
173 ms |
812 KB |
Output is correct |
8 |
Runtime error |
4 ms |
4444 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |