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>
#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 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... |