| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1362032 | SulA | Inside information (BOI21_servers) | C++20 | 148 ms | 2644 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 120'001;
int L[N], R[N];
const int offset = 1 << 18;
int tree[2*offset];
void update(int i, int x) {
tree[i += offset] += x;
while (i >>= 1)
tree[i] = tree[2*i] + tree[2*i + 1];
}
int query(int k) {
int res = 0;
for (int pos = k + offset; pos > 1; pos /= 2) {
if (pos % 2)
res += tree[pos];
pos /= 2;
}
return res;
}
int main() {
int n,k; cin >> n >> k;
for (int i = 1; i <= n; i++) {
L[i] = R[i] = i;
update(L[i], 1);
update(R[i] + 1, -1);
}
for (int _ = 0; _ < n+k-1; _++) {
char t;
int a,b; cin >> t;
if (t == 'S') {
cin >> a >> b;
if (a > b) swap(a, b);
update(1 + R[a], 1);
update(L[b], -1);
R[a] = R[b];
L[b] = L[a];
update(1 + R[a], -1);
update(L[b], 1);
} else if (t == 'Q') {
cin >> a >> b;
cout << (L[a] <= b && b <= R[a] ? "yes" : "no") << "\n";
} else {
cin >> b;
cout << query(b) << "\n";
}
}
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
