| 比赛 |
2026.9.5 |
评测结果 |
AAAAAAAAAAAAAAA |
| 题目名称 |
To-Do List |
最终得分 |
100 |
| 用户昵称 |
郑霁桓 |
运行时间 |
8.603 s |
| 代码语言 |
C++ |
内存使用 |
39.93 MiB |
| 提交时间 |
2026-09-05 10:55:02 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int q,xx,yy,x[1000050],y[1000050],ct,s0[4000050];
long long tr[4000050],a[1000050];
const int N=1e6,M=1e6+3;
char c;
inline void build(int l,int r,int p){
s0[p]=0;
tr[p]=l-1;
if(l==r) return;
int md=(l+r)>>1;
build(l,md,p*2);
build(md+1,r,p*2+1);
return;
}
inline void ad(int x,int l,int r,int p,int v){
if(l==r){
a[l]+=v,s0[p]=0;
tr[p]=l+a[l]-1;
return;
}
int md=(l+r)>>1;
if(x<=md) ad(x,l,md,p*2,v);
else ad(x,md+1,r,p*2+1,v);
if(tr[p*2+1]==md){
tr[p]=tr[p*2];
s0[p]=s0[p*2];
}else if(tr[p*2]==l-1){
tr[p]=tr[p*2+1];
s0[p]=md-l+1+s0[p*2+1];
}else if(tr[p*2]-md>s0[p*2+1]){
tr[p]=tr[p*2+1]+tr[p*2]-md-s0[p*2+1];
s0[p]=s0[p*2];
}else{
tr[p]=tr[p*2+1];
s0[p]=s0[p*2]+s0[p*2+1]-(tr[p*2]-md);
}
return;
}
int main(){
freopen("List.in","r",stdin);
freopen("List.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>q;
build(1,N,1);
while(q--){
cin>>c>>xx,xx=(xx+tr[1])%M;
if(c=='A'){
cin>>yy,yy=(yy+tr[1])%M;
x[++ct]=xx;
y[ct]=yy;
ad(xx,1,N,1,yy);
}else ad(x[xx],1,N,1,-y[xx]);
cout<<tr[1]<<"\n";
}
return 0;
}