#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e4+5;
set<int> graph[N];
int cnt[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k; cin>>n>>k;
for(int i=1; i<=n; i++){
graph[i].insert(i);
cnt[i]=1;
}
for(int i=0; i<n+k-1; i++){
char c; cin>>c;
if(c=='S'){
int u, v; cin>>u>>v;
for(auto x: graph[v]){
if(graph[u].find(x)==graph[u].end()){
cnt[x]+=1;
graph[u].insert(x);
}
}
for(auto x: graph[u]){
if(graph[v].find(x)==graph[v].end()){
cnt[x]+=1;
graph[v].insert(x);
}
}
}
else if(c=='Q'){
int v, chunk ; cin>>v>>chunk;
if(graph[v].find(chunk)==graph[v].end()){
cout<<"no"<<"\n";
}
else{
cout<<"yes"<<"\n";
}
}
else{
int v; cin>>v;
cout<<cnt[v]<<"\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Correct |
27 ms |
2648 KB |
Output is correct |
3 |
Correct |
273 ms |
48340 KB |
Output is correct |
4 |
Correct |
27 ms |
2136 KB |
Output is correct |
5 |
Correct |
31 ms |
2140 KB |
Output is correct |
6 |
Correct |
1714 ms |
377764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Correct |
27 ms |
2648 KB |
Output is correct |
3 |
Correct |
273 ms |
48340 KB |
Output is correct |
4 |
Correct |
27 ms |
2136 KB |
Output is correct |
5 |
Correct |
31 ms |
2140 KB |
Output is correct |
6 |
Correct |
1714 ms |
377764 KB |
Output is correct |
7 |
Correct |
18 ms |
1116 KB |
Output is correct |
8 |
Correct |
24 ms |
2436 KB |
Output is correct |
9 |
Correct |
279 ms |
60308 KB |
Output is correct |
10 |
Correct |
22 ms |
2124 KB |
Output is correct |
11 |
Correct |
22 ms |
1884 KB |
Output is correct |
12 |
Correct |
1680 ms |
377636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2392 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1112 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2392 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1116 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1116 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2392 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Runtime error |
2 ms |
2392 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1188 KB |
Output is correct |
2 |
Correct |
32 ms |
2388 KB |
Output is correct |
3 |
Correct |
236 ms |
48128 KB |
Output is correct |
4 |
Correct |
26 ms |
2132 KB |
Output is correct |
5 |
Correct |
33 ms |
2128 KB |
Output is correct |
6 |
Correct |
1672 ms |
377760 KB |
Output is correct |
7 |
Correct |
22 ms |
1624 KB |
Output is correct |
8 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1188 KB |
Output is correct |
2 |
Correct |
32 ms |
2388 KB |
Output is correct |
3 |
Correct |
236 ms |
48128 KB |
Output is correct |
4 |
Correct |
26 ms |
2132 KB |
Output is correct |
5 |
Correct |
33 ms |
2128 KB |
Output is correct |
6 |
Correct |
1672 ms |
377760 KB |
Output is correct |
7 |
Correct |
22 ms |
1624 KB |
Output is correct |
8 |
Runtime error |
2 ms |
2396 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |