結果

問題 No.2809 Sort Query
ユーザー chineristAC
提出日時 2024-07-12 21:15:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 3,650 bytes
コンパイル時間 2,864 ms
コンパイル使用メモリ 186,020 KB
最終ジャッジ日時 2025-02-22 03:24:48
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 3 RE * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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];
vec<int> sorted_idx(N,0);
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];
}
while (Q--){
int t;
cin>>t;
if (t == 1){
int k,x;
cin>>k>>x;
k--;
if (!update_idx.count(k)){
sorted_idx[k] = 0;
update_idx.insert(k);
}
update_val[k] = x;
}
else if (t == 2){
for (auto i:update_idx){
sorted_val_set.erase({A[i],i});
sorted_val_set.insert({update_val[i],i});
sorted_idx[i] = 1;
}
update_idx.clear();
update_val.clear();
}
else{
int k;
cin>>k;
k--;
if (sorted_idx[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();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0