This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
int n,q;
cin>>n>>q;
vector<vector<bool>> vis(n+1,vector<bool>(n+1));
for(int i=1;i<=n;i++) vis[i][i] = 1;
vector<int> cnt(n+1,1);
for(int qq=0;qq<n+q-1;qq++){
char c;
int a,b;
cin>>c>>a;
if(c != 'C') cin>>b;
if(c == 'S'){
for(int j=1;j<=n;j++){
cnt[j] += vis[a][j] ^ vis[b][j];
vis[a][j] = vis[a][j] | vis[b][j];
}
vis[b] = vis[a];
}
else if(c == 'C') cout<<cnt[a]<<endl;
else cout<<(vis[a][b] ? "yes" : "no")<<endl;
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |