#include <bits/stdc++.h>
using namespace std;
set<int>sp[8001];
int n,k,sum[8001];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)sum[i]=1,sp[i].insert(i);
k=k+n-1;
while(k--){
char s;cin>>s;
if(s=='S'){
int x,y;cin>>x>>y;
for(auto j:sp[x])
{
sp[y].insert(j);
}
for(auto j:sp[y])
{
sp[x].insert(j);
}
for(auto j:sp[y])
{
sum[j]++;
}
}else if(s=='Q'){
int a,d;cin>>a>>d;
if(sp[a].find(d)!=sp[a].end()){
cout<<"yes"<<endl;
}else cout<<"no"<<endl;
}else{
int x;cin>>x;
cout<<sum[x]<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
160 ms |
1104 KB |
Output is correct |
2 |
Correct |
194 ms |
2448 KB |
Output is correct |
3 |
Correct |
379 ms |
47956 KB |
Output is correct |
4 |
Correct |
181 ms |
1964 KB |
Output is correct |
5 |
Correct |
174 ms |
1968 KB |
Output is correct |
6 |
Correct |
1824 ms |
377000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
160 ms |
1104 KB |
Output is correct |
2 |
Correct |
194 ms |
2448 KB |
Output is correct |
3 |
Correct |
379 ms |
47956 KB |
Output is correct |
4 |
Correct |
181 ms |
1964 KB |
Output is correct |
5 |
Correct |
174 ms |
1968 KB |
Output is correct |
6 |
Correct |
1824 ms |
377000 KB |
Output is correct |
7 |
Correct |
156 ms |
1104 KB |
Output is correct |
8 |
Correct |
188 ms |
2248 KB |
Output is correct |
9 |
Correct |
394 ms |
59984 KB |
Output is correct |
10 |
Correct |
181 ms |
1876 KB |
Output is correct |
11 |
Correct |
165 ms |
1712 KB |
Output is correct |
12 |
Correct |
1760 ms |
377380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
1104 KB |
Output is correct |
2 |
Runtime error |
3 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
1104 KB |
Output is correct |
2 |
Runtime error |
3 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
172 ms |
1100 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2136 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
172 ms |
1100 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2136 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
1072 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
1072 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
1108 KB |
Output is correct |
2 |
Runtime error |
1 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
1108 KB |
Output is correct |
2 |
Runtime error |
1 ms |
2140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
1108 KB |
Output is correct |
2 |
Correct |
178 ms |
2264 KB |
Output is correct |
3 |
Correct |
348 ms |
47956 KB |
Output is correct |
4 |
Correct |
180 ms |
2128 KB |
Output is correct |
5 |
Correct |
177 ms |
2000 KB |
Output is correct |
6 |
Correct |
1849 ms |
377188 KB |
Output is correct |
7 |
Correct |
154 ms |
1108 KB |
Output is correct |
8 |
Runtime error |
2 ms |
2140 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
1108 KB |
Output is correct |
2 |
Correct |
178 ms |
2264 KB |
Output is correct |
3 |
Correct |
348 ms |
47956 KB |
Output is correct |
4 |
Correct |
180 ms |
2128 KB |
Output is correct |
5 |
Correct |
177 ms |
2000 KB |
Output is correct |
6 |
Correct |
1849 ms |
377188 KB |
Output is correct |
7 |
Correct |
154 ms |
1108 KB |
Output is correct |
8 |
Runtime error |
2 ms |
2140 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |