#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q; cin >> n >> q;
q+=n-1;
vector<set<int>> v(n);
for(int i = 0; i < n; i++) v[i].insert(i);
while(q--){
str tt; int a, b; cin >> tt >> a >> b; a--, b--;
if(tt == "S"){
for(int x: v[b]) v[a].insert(x);
v[b] = v[a];
}
else{
cout << (v[a].find(b) != v[a].end() ? "yes":"no") << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1492 KB |
Output is correct |
2 |
Correct |
48 ms |
3512 KB |
Output is correct |
3 |
Correct |
208 ms |
49036 KB |
Output is correct |
4 |
Correct |
38 ms |
3156 KB |
Output is correct |
5 |
Correct |
40 ms |
3060 KB |
Output is correct |
6 |
Correct |
1339 ms |
378308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1492 KB |
Output is correct |
2 |
Correct |
48 ms |
3512 KB |
Output is correct |
3 |
Correct |
208 ms |
49036 KB |
Output is correct |
4 |
Correct |
38 ms |
3156 KB |
Output is correct |
5 |
Correct |
40 ms |
3060 KB |
Output is correct |
6 |
Correct |
1339 ms |
378308 KB |
Output is correct |
7 |
Runtime error |
2 ms |
596 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1560 KB |
Output is correct |
2 |
Runtime error |
1500 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1560 KB |
Output is correct |
2 |
Runtime error |
1500 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1512 KB |
Output is correct |
2 |
Correct |
230 ms |
34616 KB |
Output is correct |
3 |
Correct |
184 ms |
34688 KB |
Output is correct |
4 |
Runtime error |
1352 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1512 KB |
Output is correct |
2 |
Correct |
230 ms |
34616 KB |
Output is correct |
3 |
Correct |
184 ms |
34688 KB |
Output is correct |
4 |
Runtime error |
1352 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1476 KB |
Output is correct |
2 |
Runtime error |
545 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1476 KB |
Output is correct |
2 |
Runtime error |
545 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1492 KB |
Output is correct |
2 |
Correct |
189 ms |
34684 KB |
Output is correct |
3 |
Correct |
187 ms |
34696 KB |
Output is correct |
4 |
Runtime error |
1337 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1492 KB |
Output is correct |
2 |
Correct |
189 ms |
34684 KB |
Output is correct |
3 |
Correct |
187 ms |
34696 KB |
Output is correct |
4 |
Runtime error |
1337 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1592 KB |
Output is correct |
2 |
Correct |
40 ms |
3564 KB |
Output is correct |
3 |
Correct |
193 ms |
49168 KB |
Output is correct |
4 |
Correct |
40 ms |
3140 KB |
Output is correct |
5 |
Correct |
37 ms |
3096 KB |
Output is correct |
6 |
Correct |
1250 ms |
378252 KB |
Output is correct |
7 |
Correct |
30 ms |
1604 KB |
Output is correct |
8 |
Runtime error |
1338 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1592 KB |
Output is correct |
2 |
Correct |
40 ms |
3564 KB |
Output is correct |
3 |
Correct |
193 ms |
49168 KB |
Output is correct |
4 |
Correct |
40 ms |
3140 KB |
Output is correct |
5 |
Correct |
37 ms |
3096 KB |
Output is correct |
6 |
Correct |
1250 ms |
378252 KB |
Output is correct |
7 |
Correct |
30 ms |
1604 KB |
Output is correct |
8 |
Runtime error |
1338 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |