結果
問題 | No.2809 Sort Query |
ユーザー | Kude |
提出日時 | 2024-07-12 23:39:00 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,913 bytes |
コンパイル時間 | 4,579 ms |
コンパイル使用メモリ | 310,276 KB |
実行使用メモリ | 43,264 KB |
最終ジャッジ日時 | 2024-07-12 23:40:19 |
合計ジャッジ時間 | 67,078 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 851 ms
43,008 KB |
testcase_12 | AC | 881 ms
43,136 KB |
testcase_13 | WA | - |
testcase_14 | AC | 836 ms
42,896 KB |
testcase_15 | AC | 887 ms
43,008 KB |
testcase_16 | AC | 871 ms
43,136 KB |
testcase_17 | AC | 833 ms
43,136 KB |
testcase_18 | AC | 869 ms
43,136 KB |
testcase_19 | AC | 851 ms
43,136 KB |
testcase_20 | AC | 809 ms
43,136 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 887 ms
43,136 KB |
testcase_32 | AC | 861 ms
43,136 KB |
testcase_33 | AC | 902 ms
43,136 KB |
testcase_34 | AC | 897 ms
43,008 KB |
testcase_35 | AC | 871 ms
43,136 KB |
testcase_36 | AC | 872 ms
43,136 KB |
testcase_37 | AC | 880 ms
43,008 KB |
testcase_38 | AC | 838 ms
43,136 KB |
testcase_39 | AC | 855 ms
43,076 KB |
testcase_40 | AC | 877 ms
43,008 KB |
testcase_41 | AC | 709 ms
43,008 KB |
testcase_42 | AC | 708 ms
43,016 KB |
testcase_43 | AC | 735 ms
43,136 KB |
testcase_44 | AC | 747 ms
43,136 KB |
testcase_45 | AC | 708 ms
43,124 KB |
testcase_46 | AC | 745 ms
43,008 KB |
testcase_47 | AC | 723 ms
43,136 KB |
testcase_48 | AC | 732 ms
43,136 KB |
testcase_49 | AC | 757 ms
43,136 KB |
testcase_50 | AC | 756 ms
43,008 KB |
testcase_51 | AC | 636 ms
24,308 KB |
testcase_52 | AC | 570 ms
24,192 KB |
testcase_53 | AC | 562 ms
24,172 KB |
testcase_54 | AC | 567 ms
24,320 KB |
testcase_55 | AC | 551 ms
24,320 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | AC | 2 ms
6,940 KB |
ソースコード
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using namespace __gnu_pbds; using TP = tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update>; using TI = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; VL a(n); rep(i, n) cin >> a[i]; TI updated; rep(i, n) updated.insert(i); // (value, id) int id_nxt = 0; TP sorted; rep(_, q) { int op; cin >> op; if (op == 1) { int k; ll x; cin >> k >> x; k--; auto [it, inserted] = updated.insert(k); if (inserted) sorted.erase(sorted.lower_bound({a[k], 0})); a[k] = x; } else if (op == 2) { for (int i : updated) { sorted.insert({a[i], id_nxt++}); } updated.clear(); } else { int k; cin >> k; k--; auto it = updated.lower_bound(k); if (it != updated.end() && *it == k) { cout << a[k] << '\n'; } else { int smaller = updated.order_of_key(k); cout << sorted.find_by_order(k - smaller)->first << '\n'; } } } }