結果
問題 | No.2809 Sort Query |
ユーザー | chineristAC |
提出日時 | 2024-07-12 21:51:37 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,705 ms / 2,000 ms |
コード長 | 4,062 bytes |
コンパイル時間 | 3,462 ms |
コンパイル使用メモリ | 192,432 KB |
実行使用メモリ | 57,216 KB |
最終ジャッジ日時 | 2024-07-12 21:53:31 |
合計ジャッジ時間 | 97,878 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1,202 ms
57,088 KB |
testcase_02 | AC | 1,205 ms
56,960 KB |
testcase_03 | AC | 1,155 ms
56,960 KB |
testcase_04 | AC | 1,234 ms
57,088 KB |
testcase_05 | AC | 1,170 ms
57,088 KB |
testcase_06 | AC | 1,133 ms
57,088 KB |
testcase_07 | AC | 1,176 ms
57,088 KB |
testcase_08 | AC | 1,135 ms
57,088 KB |
testcase_09 | AC | 1,141 ms
57,172 KB |
testcase_10 | AC | 1,152 ms
57,088 KB |
testcase_11 | AC | 1,437 ms
57,088 KB |
testcase_12 | AC | 1,484 ms
57,088 KB |
testcase_13 | AC | 1,469 ms
57,088 KB |
testcase_14 | AC | 1,516 ms
57,216 KB |
testcase_15 | AC | 1,435 ms
57,088 KB |
testcase_16 | AC | 1,507 ms
57,088 KB |
testcase_17 | AC | 1,504 ms
56,960 KB |
testcase_18 | AC | 1,491 ms
57,088 KB |
testcase_19 | AC | 1,445 ms
56,960 KB |
testcase_20 | AC | 1,492 ms
57,088 KB |
testcase_21 | AC | 1,673 ms
57,088 KB |
testcase_22 | AC | 1,673 ms
56,960 KB |
testcase_23 | AC | 1,705 ms
57,088 KB |
testcase_24 | AC | 1,679 ms
56,960 KB |
testcase_25 | AC | 1,674 ms
57,088 KB |
testcase_26 | AC | 1,538 ms
56,960 KB |
testcase_27 | AC | 1,597 ms
56,960 KB |
testcase_28 | AC | 1,591 ms
57,088 KB |
testcase_29 | AC | 1,594 ms
57,088 KB |
testcase_30 | AC | 1,501 ms
57,000 KB |
testcase_31 | AC | 1,449 ms
57,068 KB |
testcase_32 | AC | 1,562 ms
57,092 KB |
testcase_33 | AC | 1,473 ms
57,088 KB |
testcase_34 | AC | 1,464 ms
57,084 KB |
testcase_35 | AC | 1,409 ms
57,088 KB |
testcase_36 | AC | 1,478 ms
56,960 KB |
testcase_37 | AC | 1,479 ms
56,960 KB |
testcase_38 | AC | 1,493 ms
56,960 KB |
testcase_39 | AC | 1,472 ms
57,088 KB |
testcase_40 | AC | 1,495 ms
57,088 KB |
testcase_41 | AC | 1,239 ms
57,088 KB |
testcase_42 | AC | 1,218 ms
57,088 KB |
testcase_43 | AC | 1,157 ms
57,088 KB |
testcase_44 | AC | 1,180 ms
56,972 KB |
testcase_45 | AC | 1,162 ms
57,088 KB |
testcase_46 | AC | 1,049 ms
57,088 KB |
testcase_47 | AC | 1,071 ms
57,088 KB |
testcase_48 | AC | 1,045 ms
57,088 KB |
testcase_49 | AC | 1,098 ms
56,960 KB |
testcase_50 | AC | 1,073 ms
57,088 KB |
testcase_51 | AC | 1,164 ms
57,088 KB |
testcase_52 | AC | 1,171 ms
57,216 KB |
testcase_53 | AC | 1,199 ms
56,960 KB |
testcase_54 | AC | 1,214 ms
57,088 KB |
testcase_55 | AC | 1,164 ms
56,976 KB |
testcase_56 | AC | 747 ms
33,792 KB |
testcase_57 | AC | 604 ms
25,472 KB |
testcase_58 | AC | 578 ms
28,800 KB |
testcase_59 | AC | 673 ms
21,504 KB |
testcase_60 | AC | 907 ms
47,488 KB |
testcase_61 | AC | 1,068 ms
56,192 KB |
testcase_62 | AC | 593 ms
26,880 KB |
testcase_63 | AC | 783 ms
36,480 KB |
testcase_64 | AC | 1,162 ms
55,680 KB |
testcase_65 | AC | 665 ms
39,680 KB |
testcase_66 | AC | 2 ms
6,944 KB |
testcase_67 | AC | 2 ms
6,940 KB |
testcase_68 | AC | 2 ms
6,940 KB |
testcase_69 | AC | 3 ms
6,944 KB |
testcase_70 | AC | 2 ms
6,940 KB |
ソースコード
#include <iostream> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <algorithm> #include <cmath> #include <iomanip> #include <random> #include <stdio.h> #include <fstream> #include <functional> #include <cassert> #include <unordered_map> #include <bitset> #include <chrono> #include <atcoder/modint> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace atcoder; using namespace __gnu_pbds; using mint = modint1000000007; #define rep(i,n) for (int i=0;i<n;i+=1) #define rrep(i,n) for (int i=n-1;i>-1;i--) #define pb push_back #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << " )\n"; template<class T> using vec = vector<T>; template<class T> using vvec = vec<vec<T>>; template<class T> using vvvec = vec<vvec<T>>; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<class T> bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template<class T> bool chmax(T &a, T b){ if (a<b){ a = b; return true; } return false; } template<class T> T sum(vec<T> x){ T res=0; for (auto e:x){ res += e; } return res; } template<class T> void printv(vec<T> x){ for (auto e:x){ cout<<e<<" "; } cout<<endl; } template<class T,class U> ostream& operator<<(ostream& os, const pair<T,U>& A){ os << "(" << A.first <<", " << A.second << ")"; return os; } template<class T> ostream& operator<<(ostream& os, const set<T>& S){ os << "set{"; for (auto a:S){ os << a; auto it = S.find(a); it++; if (it!=S.end()){ os << ", "; } } os << "}"; return os; } template<class T> ostream& operator<<(ostream& os, const tuple<T,T,T>& a){ auto [x,y,z] = a; os << "(" << x << ", " << y << ", " << z << ")"; return os; } template<class T> ostream& operator<<(ostream& os, const map<ll,T>& A){ os << "map{"; for (auto e:A){ os << e.first; os << ":"; os << e.second; os << ", "; } os << "}"; return os; } template<class T> ostream& operator<<(ostream& os, const vec<T>& A){ os << "["; rep(i,A.size()){ os << A[i]; if (i!=A.size()-1){ os << ", "; } } os << "]" ; return os; } ostream& operator<<(ostream& os, const mint& a){ os << a.val(); return os; } void solve(){ int N,Q; cin>>N>>Q; vec<ll> A(N); rep(i,N) cin>>A[i]; tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> sorted_val_set; set<int> update_idx = {}; rep(i,N){ update_idx.insert(i); } map<int,ll> update_val; rep(i,N){ update_val[i] = A[i]; } rep(i,N){ sorted_val_set.insert({ll(i),ll(i)}); } int nxt = N; while (Q--){ int t; cin>>t; if (t == 1){ int k;ll x; cin>>k>>x; k--; if (!update_idx.count(k)){ update_idx.insert(k); } update_val[k] = x; } else if (t == 2){ int tmp = 0; //debug(update_idx); //assert (sorted_val_set.size() == N); for (auto i:update_idx){ auto [val,x] = *sorted_val_set.find_by_order(i-tmp); //debug(make_pair(val,x)); sorted_val_set.erase({val,x}); tmp++; //sorted_val_set.insert({update_val[i],i}); //for (auto [a,b]:sorted_val_set){ //cout << a << " " << b << "\n"; //} } for (auto i:update_idx){ sorted_val_set.insert({update_val[i],ll(nxt)}); nxt++; } update_idx.clear(); update_val.clear(); } else{ int k; cin>>k; k--; if (!update_idx.count(k)){ auto [val,x] = *sorted_val_set.find_by_order(k); cout << val << "\n"; } else{ cout << update_val[k] << "\n"; } } } } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); int T = 1; while (T--){ solve(); } }