#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=1e18;
const int mod=1e9+7;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,q;cin>>n>>q;
q=n+q-1;
vector<bitset<120000>> v(n);
for(int i=0;i<n;i++){
v[i][i]=1;
}
for(int i=0;i<q;i++){
char c;cin>>c;
if(c=='S'){
int a,b;cin>>a>>b;a--;b--;
v[a]|=v[b];
v[b]=v[a];
}
if(c=='Q'){
int a,b;cin>>a>>b;a--;b--;
if(v[a][b]){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
}
if(c=='C'){
int p;cin>>p;p--;
cout<<0<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
2248 KB |
Output is correct |
2 |
Correct |
196 ms |
60740 KB |
Output is correct |
3 |
Correct |
186 ms |
60800 KB |
Output is correct |
4 |
Correct |
195 ms |
60744 KB |
Output is correct |
5 |
Correct |
196 ms |
60684 KB |
Output is correct |
6 |
Correct |
189 ms |
60752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
2248 KB |
Output is correct |
2 |
Correct |
196 ms |
60740 KB |
Output is correct |
3 |
Correct |
186 ms |
60800 KB |
Output is correct |
4 |
Correct |
195 ms |
60744 KB |
Output is correct |
5 |
Correct |
196 ms |
60684 KB |
Output is correct |
6 |
Correct |
189 ms |
60752 KB |
Output is correct |
7 |
Incorrect |
155 ms |
2204 KB |
Extra information in the output file |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
2248 KB |
Output is correct |
2 |
Runtime error |
228 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
2248 KB |
Output is correct |
2 |
Runtime error |
228 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
2152 KB |
Output is correct |
2 |
Runtime error |
202 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
2152 KB |
Output is correct |
2 |
Runtime error |
202 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
2208 KB |
Output is correct |
2 |
Runtime error |
200 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
2208 KB |
Output is correct |
2 |
Runtime error |
200 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
2168 KB |
Output is correct |
2 |
Runtime error |
216 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
2168 KB |
Output is correct |
2 |
Runtime error |
216 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
2172 KB |
Output is correct |
2 |
Correct |
213 ms |
60856 KB |
Output is correct |
3 |
Correct |
201 ms |
60776 KB |
Output is correct |
4 |
Correct |
195 ms |
60696 KB |
Output is correct |
5 |
Correct |
198 ms |
60768 KB |
Output is correct |
6 |
Correct |
197 ms |
60784 KB |
Output is correct |
7 |
Correct |
151 ms |
2216 KB |
Output is correct |
8 |
Runtime error |
187 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
2172 KB |
Output is correct |
2 |
Correct |
213 ms |
60856 KB |
Output is correct |
3 |
Correct |
201 ms |
60776 KB |
Output is correct |
4 |
Correct |
195 ms |
60696 KB |
Output is correct |
5 |
Correct |
198 ms |
60768 KB |
Output is correct |
6 |
Correct |
197 ms |
60784 KB |
Output is correct |
7 |
Correct |
151 ms |
2216 KB |
Output is correct |
8 |
Runtime error |
187 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |