This documentation is automatically generated by competitive-verifier/competitive-verifier
// @brief Ordered Set
#define PROBLEM "https://judge.yosupo.jp/problem/ordered_set"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
//#include "blazingio/blazingio.min.hpp"
#include "cp-algo/structures/fenwick_set.hpp"
#include "cp-algo/util/compress_coords.hpp"
using namespace std;
using cp_algo::structures::fenwick_set;
void solve() {
int n, q;
cin >> n >> q;
cp_algo::big_vector<int> a(n, 0);
cp_algo::big_vector<reference_wrapper<int>> coords;
for(auto &it: a) {
cin >> it;
coords.push_back(ref(it));
}
cp_algo::big_vector<pair<int, int>> queries(q, pair{0, 0});
for(auto &[t, x]: queries) {
cin >> t >> x;
if(t != 2) {
coords.push_back(ref(x));
}
}
auto values = cp_algo::compress_coords(coords);
const int maxc = 1e6;
fenwick_set<maxc> me(a);
for(auto [t, x]: queries) {
if(t == 0) {
me.insert(x);
} else if(t == 1) {
me.erase(x);
} else if(t == 2) {
auto res = (int)me.find_by_order(x-1);
cout << (res == -1 ? -1 : values[res]) << '\n';
} else if(t == 3) {
cout << me.order_of_key(x+1) << '\n';
} else if(t == 4) {
auto res = (int)me.pre_upper_bound(x);
cout << (res == -1 ? -1 : values[res]) << '\n';
} else if(t == 5) {
auto res = (int)me.lower_bound(x);
cout << (res == -1 ? -1 : values[res]) << '\n';
}
}
}
signed main() {
//freopen("input.txt", "r", stdin);
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
while(t--) {
solve();
}
}
Traceback (most recent call last):
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj_resolve/resolver.py", line 181, in resolve
bundled_code = language.bundle(path, basedir=basedir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 252, in bundle
bundler.update(path)
File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 327, in update
assert len(lines) == len(uncommented_lines)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
| Env | Name | Status | Elapsed | Memory |
|---|---|---|---|---|
| g++ | example_00 |
|
5 ms | 4 MB |
| g++ | example_01 |
|
4 ms | 4 MB |
| g++ | max_random_00 |
|
89 ms | 17 MB |
| g++ | max_random_01 |
|
91 ms | 17 MB |
| g++ | max_random_02 |
|
71 ms | 18 MB |
| g++ | max_random_03 |
|
67 ms | 18 MB |
| g++ | max_random_04 |
|
79 ms | 8 MB |
| g++ | max_random_05 |
|
95 ms | 18 MB |
| g++ | max_random_06 |
|
103 ms | 18 MB |
| g++ | max_random_07 |
|
103 ms | 18 MB |
| g++ | max_random_08 |
|
100 ms | 17 MB |
| g++ | max_random_09 |
|
103 ms | 17 MB |
| g++ | max_random_10 |
|
73 ms | 18 MB |
| g++ | max_random_11 |
|
69 ms | 18 MB |
| g++ | max_random_12 |
|
84 ms | 8 MB |
| g++ | max_random_13 |
|
95 ms | 18 MB |
| g++ | max_random_14 |
|
110 ms | 18 MB |
| g++ | max_random_15 |
|
115 ms | 18 MB |
| g++ | max_random_16 |
|
146 ms | 29 MB |
| g++ | max_random_17 |
|
157 ms | 29 MB |
| g++ | max_random_18 |
|
125 ms | 30 MB |
| g++ | max_random_19 |
|
121 ms | 30 MB |
| g++ | max_random_20 |
|
143 ms | 20 MB |
| g++ | max_random_21 |
|
147 ms | 30 MB |
| g++ | max_random_22 |
|
160 ms | 30 MB |
| g++ | max_random_23 |
|
160 ms | 30 MB |
| g++ | max_random_24 |
|
160 ms | 29 MB |
| g++ | max_random_25 |
|
161 ms | 29 MB |
| g++ | max_random_26 |
|
130 ms | 30 MB |
| g++ | max_random_27 |
|
123 ms | 30 MB |
| g++ | max_random_28 |
|
157 ms | 20 MB |
| g++ | max_random_29 |
|
145 ms | 30 MB |
| g++ | max_random_30 |
|
166 ms | 30 MB |
| g++ | max_random_31 |
|
173 ms | 30 MB |
| g++ | small_00 |
|
66 ms | 14 MB |
| g++ | small_01 |
|
72 ms | 17 MB |
| g++ | small_02 |
|
71 ms | 17 MB |