Submission #657574

#TimeUsernameProblemLanguageResultExecution timeMemory
657574TimDeeInside information (BOI21_servers)C++17
2.50 / 100
3568 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define forn(i,n) for (int i=0; i<n; ++i) void solve() { int n,q; cin>>n>>q; vector<set<int>> a(n+1); forn(i,n) a[i+1].insert(i+1); forn(Q,n-1+q) { char c; cin>>c; if (c=='S') { int u,v; cin>>u>>v; for (auto x:a[u]) a[v].insert(x); for (auto x:a[v]) a[u].insert(x); } else if (c=='Q') { int u,x; cin>>u>>x; cout << (a[u].count(x)?"yes\n":"no\n"); } else { int x; cin>>x; int ans=0; forn(i,n) ans+=a[i+1].count(x); cout<<ans<<'\n'; } } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...