結果
| 問題 |
No.2935 Division Into 3 (Mex Edition)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-27 02:48:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 808 bytes |
| コンパイル時間 | 2,915 ms |
| コンパイル使用メモリ | 246,324 KB |
| 実行使用メモリ | 9,344 KB |
| 最終ジャッジ日時 | 2024-09-27 04:48:10 |
| 合計ジャッジ時間 | 15,081 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n;cin>>n;
vector<int> a(n);for(auto&&e:a)cin>>e;
int q;cin>>q;
int res_prev=0;
while(q--){
int x,y;cin>>x>>y;
int l=x^res_prev,r=y^res_prev;
l--;
assert(0<=l&&r-l>=2&&r<=n);
// cout<<"l r : "<<l<<" "<<r<<endl;
vector<int> cnt(r-l);
for(int i=l;i<r;i++){
if(a[i]<r-l)cnt[a[i]]++;
}
// for(auto&&e:cnt)cout<<e<<" ";
// cout<<endl;
vector<int> v(3);
for(int i=0;i<3;i++){
while(v[i]<r-l&&cnt[v[i]]>=i+1){
v[i]++;
}
}
int res=0;
if(v[2]){
res=v[0]+v[1]+v[2];
}else if(v[1]){
res=v[0]+v[1]+min(0,r-l-v[0]-v[1]-1);
}else if(v[0]){
res=v[0]+min(0,r-l-v[0]-2);
}else{
res=0;
}
cout<<res<<endl;
res_prev=res;
}
}