結果
問題 | No.2809 Sort Query |
ユーザー | pitP |
提出日時 | 2024-07-13 16:10:29 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,526 bytes |
コンパイル時間 | 8,462 ms |
コンパイル使用メモリ | 338,932 KB |
実行使用メモリ | 36,800 KB |
最終ジャッジ日時 | 2024-07-13 16:11:11 |
合計ジャッジ時間 | 41,916 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
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 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 244 ms
19,296 KB |
testcase_37 | AC | 242 ms
19,492 KB |
testcase_38 | AC | 241 ms
19,344 KB |
testcase_39 | AC | 243 ms
19,504 KB |
testcase_40 | AC | 242 ms
19,308 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
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 <atcoder/all> using namespace std; using namespace atcoder; istream &operator>>(istream &is, modint &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint &a) { return os << a.val(); } istream &operator>>(istream &is, modint998244353 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint998244353 &a) { return os << a.val(); } istream &operator>>(istream &is, modint1000000007 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint1000000007 &a) { return os << a.val(); } typedef long long ll; typedef vector<vector<int>> Graph; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define FOR(i,l,r) for (int i = l;i < (int)(r); i++) #define rep(i,n) for (int i = 0;i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define my_sort(x) sort(x.begin(), x.end()) #define my_max(x) *max_element(all(x)) #define my_min(x) *min_element(all(x)) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = (1<<30) - 1; const ll LINF = (1LL<<62) - 1; const int MOD = 998244353; const int MOD2 = 1e9+7; const double PI = acos(-1); vector<int> di = {1,0,-1,0}; vector<int> dj = {0,1,0,-1}; #ifdef LOCAL # include <debug_print.hpp> # define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define debug(...) (static_cast<void>(0)) #endif using S = ll; S op(S a, S b){ return a + b; } S e(){ return 0ll; } S target; bool g(S x){ return x < target; } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); int N, Q; cin >> N >> Q; vector<ll> A(N); rep(i, N) cin >> A[i]; vector<ll> Z = A; Z.push_back(-LINF); vector<int> f(Q), k(Q); vector<ll> x(Q); rep(i, Q){ cin >> f[i]; if(f[i] == 1){ cin >> k[i] >> x[i]; k[i]--; Z.push_back(x[i]); } if(f[i] == 2) if(f[i] == 3){ cin >> k[i]; k[i]--; } } sort(all(Z)); Z.erase(unique(all(Z)), Z.end()); int L = Z.size(); segtree<S, op, e> seg(L); rep(i, N) { A[i] = lower_bound(all(Z), A[i]) - Z.begin(); seg.set(A[i], seg.get(A[i]) + 1); } vector<int> lazy; vector<int> B(N); rep(i, N) { B[i] = A[i]; lazy.push_back(i); } rep(i, Q){ debug(i, lazy, B); if(f[i] == 1){ lazy.push_back(k[i]); B[k[i]] = lower_bound(all(Z), x[i]) - Z.begin(); } if(f[i] == 2){ sort(all(lazy)); lazy.erase(unique(all(lazy)), lazy.end()); reverse(all(lazy)); for(auto &l : lazy){ target = l + 1; debug(target); int r = seg.max_right<g>(0); debug(target, r); seg.set(r, seg.get(r) - 1); } for(auto &l : lazy){ seg.set(B[l], seg.get(B[l]) + 1); B[l] = -1; } lazy.clear(); } if(f[i] == 3){ if(B[i] != -1){ cout << Z[B[k[i]]] << endl; } else{ target = k[i] + 1; int k = seg.max_right<g>(0); cout << Z[k] << endl; } } } }