結果
| 問題 |
No.2809 Sort Query
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-07-12 21:39:57 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,753 bytes |
| コンパイル時間 | 3,571 ms |
| コンパイル使用メモリ | 272,720 KB |
| 実行使用メモリ | 35,296 KB |
| 最終ジャッジ日時 | 2024-07-12 21:40:12 |
| 合計ジャッジ時間 | 14,016 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 -- * 69 |
ソースコード
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n,q;
cin >> n >> q;
set<ll> st;
__gnu_cxx::rope<ll> p(n,0);
rep(i,n){
ll a;
cin >> a;
p.erase(i,1);
p.insert(i,a);
st.insert(i);
}
while(q--){
ll t;
cin >> t;
if(t==1){
ll k,x;
cin >> k >> x;
k--;
p.erase(k,1);
p.insert(k,x);
st.insert(k);
}
if(t==2){
vector<ll> v;
for(auto i:st) v.push_back(p[i]);
ll d=0;
for(auto i:st){
p.erase(i-d,1);
d++;
}
for(auto i:v){
ll ok=-1,ng=len(p);
while(1<abs(ok-ng)){
ll mid=(ok+ng)/2;
if(p[mid]<i) ok=mid;
else ng=mid;
}
p.insert(ok+1,i);
}
st.clear();
}
if(t==3){
ll k;
cin >> k;
k--;
cout << p[k] << '\n';
}
}
}
FplusFplusF