#include <bits/stdc++.h>
using namespace std;
int main(){
int n,q;cin>>n>>q;
q+=n-1;
int mer[n+1];
for(int i = 1;i<=n;i++)mer[i] = -1;
int ind = 0;
while(q--){
char c;cin>>c;
if(c=='S'){
int a,b;cin>>a>>b;
if(a>b)swap(a,b);
mer[b] = ind;ind++;
}if(c=='C'){
int a;cin>>a;
if(mer[a]==-1)cout<<1<<endl;
else cout<<1+ind-mer[a]<<endl;
}if(c=='Q'){
int a,b;cin>>a>>b;
if(b==1){
if(a==1||mer[a]!=-1)cout<<"yes\n";
else cout<<"no\n";
continue;
}
if(a==b)cout<<"yes\n";
else{
if(a==1&&mer[b]==-1)cout<<"no\n";
else if(a!=1&&(mer[a]<mer[b]||(mer[a]==-1||mer[b]==-1)))cout<<"no\n";
else cout<<"yes\n";
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
171 ms |
1008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
171 ms |
1008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
752 KB |
Output is correct |
2 |
Correct |
230 ms |
1104 KB |
Output is correct |
3 |
Correct |
229 ms |
1104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
752 KB |
Output is correct |
2 |
Correct |
230 ms |
1104 KB |
Output is correct |
3 |
Correct |
229 ms |
1104 KB |
Output is correct |
4 |
Incorrect |
170 ms |
592 KB |
Extra information in the output file |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
169 ms |
728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
169 ms |
728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
170 ms |
712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
170 ms |
712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
170 ms |
744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
170 ms |
744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
179 ms |
764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
179 ms |
764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |