Submission #444411

#TimeUsernameProblemLanguageResultExecution timeMemory
444411yungyaoInside information (BOI21_servers)C++17
5 / 100
3012 ms384088 KiB
using namespace std; #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <utility> #include <memory.h> #include <map> #include <set> typedef long long LL; typedef pair<int,int> pii; #define F first #define S second #define pb push_back #define mkp make_pair #define iter(x) x.begin(),x.end() const int maxn = 12e4 + 100; int n,k; set <int> st[maxn]; int cnt[maxn]; void brutesolve(){ for (int i=1;i<=n;++i) {st[i].insert(i); cnt[i] = 1;} for (int _=n+k-1;_--;){ char o; cin >> o; if (o == 'S'){ int u,v; cin >> u >> v; set <int> ele; for (auto i:st[u]) {ele.insert(i); ++cnt[i];} for (auto i:st[v]) {ele.insert(i); ++cnt[i];} st[u] = ele; st[v] = ele; } else if (o == 'Q'){ int a,b; cin >> a >> b; cout << (st[a].find(b) != st[a].end() ? "yes\n" : "no\n"); } else{ int c; cin >> c; cout << cnt[c] << '\n'; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; if (n <= 4000) brutesolve(); 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...