#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i=0; i<n; ++i)
void solve() {
int n,q; cin>>n>>q;
vector<set<int>> a(n+1);
forn(i,n) a[i+1].insert(i+1);
forn(Q,n-1+q) {
char c;
cin>>c;
if (c=='S') {
int u,v; cin>>u>>v;
for (auto x:a[u]) a[v].insert(x);
for (auto x:a[v]) a[u].insert(x);
} else if (c=='Q') {
int u,x; cin>>u>>x;
cout << (a[u].count(x)?"yes\n":"no\n");
} else {
cout<<"0\n";
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
30 ms |
3628 KB |
Output is correct |
3 |
Correct |
236 ms |
49088 KB |
Output is correct |
4 |
Correct |
28 ms |
3176 KB |
Output is correct |
5 |
Correct |
28 ms |
3032 KB |
Output is correct |
6 |
Correct |
1748 ms |
378388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
30 ms |
3628 KB |
Output is correct |
3 |
Correct |
236 ms |
49088 KB |
Output is correct |
4 |
Correct |
28 ms |
3176 KB |
Output is correct |
5 |
Correct |
28 ms |
3032 KB |
Output is correct |
6 |
Correct |
1748 ms |
378388 KB |
Output is correct |
7 |
Incorrect |
17 ms |
1472 KB |
Extra information in the output file |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
652 KB |
Output is correct |
2 |
Runtime error |
2107 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
652 KB |
Output is correct |
2 |
Runtime error |
2107 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
596 KB |
Output is correct |
2 |
Correct |
163 ms |
34052 KB |
Output is correct |
3 |
Correct |
178 ms |
34208 KB |
Output is correct |
4 |
Runtime error |
1200 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
596 KB |
Output is correct |
2 |
Correct |
163 ms |
34052 KB |
Output is correct |
3 |
Correct |
178 ms |
34208 KB |
Output is correct |
4 |
Runtime error |
1200 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Runtime error |
2697 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Runtime error |
2697 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
170 ms |
34200 KB |
Output is correct |
3 |
Correct |
179 ms |
34184 KB |
Output is correct |
4 |
Runtime error |
1192 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
170 ms |
34200 KB |
Output is correct |
3 |
Correct |
179 ms |
34184 KB |
Output is correct |
4 |
Runtime error |
1192 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
31 ms |
3468 KB |
Output is correct |
3 |
Correct |
250 ms |
49080 KB |
Output is correct |
4 |
Correct |
30 ms |
3148 KB |
Output is correct |
5 |
Correct |
29 ms |
3020 KB |
Output is correct |
6 |
Correct |
1803 ms |
378508 KB |
Output is correct |
7 |
Correct |
19 ms |
1604 KB |
Output is correct |
8 |
Runtime error |
2103 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
596 KB |
Output is correct |
2 |
Correct |
31 ms |
3468 KB |
Output is correct |
3 |
Correct |
250 ms |
49080 KB |
Output is correct |
4 |
Correct |
30 ms |
3148 KB |
Output is correct |
5 |
Correct |
29 ms |
3020 KB |
Output is correct |
6 |
Correct |
1803 ms |
378508 KB |
Output is correct |
7 |
Correct |
19 ms |
1604 KB |
Output is correct |
8 |
Runtime error |
2103 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |