#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=120005;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
28 ms |
7972 KB |
Output is correct |
3 |
Correct |
215 ms |
53412 KB |
Output is correct |
4 |
Correct |
27 ms |
7608 KB |
Output is correct |
5 |
Correct |
31 ms |
7432 KB |
Output is correct |
6 |
Correct |
1640 ms |
382944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
28 ms |
7972 KB |
Output is correct |
3 |
Correct |
215 ms |
53412 KB |
Output is correct |
4 |
Correct |
27 ms |
7608 KB |
Output is correct |
5 |
Correct |
31 ms |
7432 KB |
Output is correct |
6 |
Correct |
1640 ms |
382944 KB |
Output is correct |
7 |
Correct |
19 ms |
6748 KB |
Output is correct |
8 |
Correct |
36 ms |
8056 KB |
Output is correct |
9 |
Correct |
247 ms |
65724 KB |
Output is correct |
10 |
Correct |
24 ms |
7512 KB |
Output is correct |
11 |
Correct |
23 ms |
7512 KB |
Output is correct |
12 |
Correct |
1584 ms |
382884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
1944 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
1944 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
153 ms |
31836 KB |
Output is correct |
3 |
Correct |
137 ms |
31896 KB |
Output is correct |
4 |
Runtime error |
1756 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
153 ms |
31836 KB |
Output is correct |
3 |
Correct |
137 ms |
31896 KB |
Output is correct |
4 |
Runtime error |
1756 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
2177 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
2177 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
133 ms |
31820 KB |
Output is correct |
3 |
Correct |
139 ms |
31784 KB |
Output is correct |
4 |
Runtime error |
1656 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
6748 KB |
Output is correct |
2 |
Correct |
133 ms |
31820 KB |
Output is correct |
3 |
Correct |
139 ms |
31784 KB |
Output is correct |
4 |
Runtime error |
1656 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
6744 KB |
Output is correct |
2 |
Correct |
29 ms |
8068 KB |
Output is correct |
3 |
Correct |
219 ms |
53548 KB |
Output is correct |
4 |
Correct |
27 ms |
7756 KB |
Output is correct |
5 |
Correct |
26 ms |
7504 KB |
Output is correct |
6 |
Correct |
1631 ms |
382904 KB |
Output is correct |
7 |
Correct |
20 ms |
6816 KB |
Output is correct |
8 |
Runtime error |
1938 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
6744 KB |
Output is correct |
2 |
Correct |
29 ms |
8068 KB |
Output is correct |
3 |
Correct |
219 ms |
53548 KB |
Output is correct |
4 |
Correct |
27 ms |
7756 KB |
Output is correct |
5 |
Correct |
26 ms |
7504 KB |
Output is correct |
6 |
Correct |
1631 ms |
382904 KB |
Output is correct |
7 |
Correct |
20 ms |
6816 KB |
Output is correct |
8 |
Runtime error |
1938 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |