結果
| 問題 | No.3167 [Cherry 7th Tune C] Cut in Queue |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-29 00:58:21 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 164 ms / 2,500 ms |
| + 960µs | |
| コード長 | 1,583 bytes |
| 記録 | |
| コンパイル時間 | 6,530 ms |
| コンパイル使用メモリ | 390,680 KB |
| 実行使用メモリ | 46,068 KB |
| 最終ジャッジ日時 | 2026-10-29 00:59:06 |
| 合計ジャッジ時間 | 17,026 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;
// using mint=modint998244353;
// using mint=modint1000000007;
// using mint2=static_modint<2>;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
using S=int;
S op(S a,S b){return a+b;}
S e(){return 0;}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,Q;
cin>>N;
vi A(N);
rep(i,0,N)cin>>A[i];
cin>>Q;
const int T=N+Q+1;
list<int>L;
vector<list<int>::iterator>it(T);
for(auto a:A){
it[a]=L.insert(L.end(),a);
}
vector<pi>q(Q);
for(auto&[t,x]:q){
cin>>t;
if(t!=2)cin>>x;
}
int b=N+1;
for(auto&[t,a]:q){
if(t!=1)continue;
if(a==0)it[b]=L.insert(L.end(),b);
else it[b]=L.insert(it[a],b);
b++;
}
vi P,pos(T);
for(auto x:L){
pos[x]=sz(P);
P.push_back(x);
}
vi init(T);
for(auto a:A){
init[pos[a]]=1;
}
segtree<S,op,e>seg(init);
b=N+1;
int d=0;
for(auto [t,k]:q){
if(t==1){
seg.set(pos[b],1);
b++;
}else if(t==2){
d++;
}else{
int rk=d+k;
int p=seg.max_right(0,[&](S sum){
return sum<rk;
});
cout<<P[p]<<'\n';
}
}
}
C