This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
const int N = 120000;
int n, k;
bitset<N> bt[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> k;
for (int i = 0; i < n; i++) {
bt[i][i] = 1;
}
for (int i = 0; i < n+k-1; i++) {
char tp;
cin >> tp;
if (tp == 'S') {
int x, y;
cin >> x >> y;
x--; y--;
// bt[x] = bt[y] = (bt[x] | bt[y]);
bt[x] |= bt[y];
bt[y] |= bt[x];
}
else if (tp == 'Q') {
int x, z;
cin >> x >> z;
x--; z--;
if (bt[x][z]) cout << "yes\n";
else cout << "no\n";
}
else {
int z;
cin >> z;
z--;
int ans = 0;
for (int i = 0; i < n; i++) {
if (bt[i][z]) ans++;
}
cout << ans << "\n";
}
}
}
# | 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... |