Submission #446877

#TimeUsernameProblemLanguageResultExecution timeMemory
446877wiwihoInside information (BOI21_servers)C++14
5 / 100
442 ms3944 KiB
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second using namespace std; typedef long long ll; using pii = pair<int, int>; int n, k; const int SZ = 4001; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; assert(n < SZ); vector<bitset<SZ>> b(n + 1); for(int i = 1; i <= n; i++) b[i].set(i); int q = n + k - 1; while(q--){ string s; cin >> s; if(s == "S"){ int u, v; cin >> u >> v; b[u] |= b[v]; b[v] |= b[u]; } else if(s == "Q"){ int a, d; cin >> a >> d; if(b[a][d]) cout << "yes\n"; else cout << "no\n"; } else{ int d; cin >> d; int ans = 0; for(int i = 1; i <= n; i++){ if(b[i][d]) ans++; } cout << ans << "\n"; } } 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...