Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
24242 liuyile 【BJ】T1 C++ 通过 100 74 MS 68912 KB 3428 2023-12-20 12:09:49

Tests(10/10):


#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" int d[50030]; int s[50030]; int n,g,r,tot; int q; int f[50030]; int w[50030*32*5]; int ls[50030*32*5]; int rs[50030*32*5]; int tg; int mat[50030]; int cnt=0; inline int nnd(){ ++cnt; w[cnt]=n+1; return cnt; } inline void pd(int x){ if(w[x]!=-1){ if(ls[x]) w[ls[x]]=w[x]; if(rs[x]) w[rs[x]]=w[x]; w[x]=-1; } } int rt=0; inline void upd(int &x,int l,int r,int L,int R,int t){ if(!x)x=nnd(); // if(x==rt){ // cout<<l<<" "<<r<<" "<<L<<" "<<R<<" "<<t<<endl; // } if(L<=l&&r<=R){ w[x]=t; // cout<<l<<" "<<r<<" "<<t<<endl; return ; } if(!ls[x])ls[x]=nnd(); if(!rs[x])rs[x]=nnd(); pd(x); int mid=l+r>>1; if(L<=mid)upd(ls[x],l,mid,L,R,t); if(R>mid)upd(rs[x],mid+1,r,L,R,t); // if(x==rt){ // cout<<endl<<endl<<endl; // } } inline int gt(int x,int l,int r,int loc){ if(!x)return n+1; if(w[x]!=-1)return w[x]; int mid=l+r>>1; if(loc<=mid)return gt(ls[x],l,mid,loc); return gt(rs[x],mid+1,r,loc); } inline void modr(int l,int r,int t){ upd(rt,0,tot-1,l,r,t); } inline void mod(int l,int r,int t){ // cout<<l<<"s"<<r<<" "; l=(l+tg)%tot; r=(r+tg)%tot; // cout<<l<<"s"<<r<<"s"<<t<<endl; if(l>r) modr(0,r,t),modr(l,tot-1,t); else modr(l,r,t); } inline void sft(int x){ tg=(tg+x%tot+tot)%tot; } inline int gt(int x){ x=(x+tg)%tot; // cout<<x<<"x"; return gt(rt,0,tot-1,x); } inline int calc(int t,int l,int r){ t+=s[r]-s[l]; if(r==n+1)return t+f[r]; t=(t+tot-1)/tot*tot; return t+f[r]; } mt19937 RD(time(0)); inline void mak(){ freopen("light.in","w",stdout); int t=10; n=3,g=r=t; q=2; cout<<n<<" "<<g<<" "<<r<<endl; for(int i=1;i<=n+1;i++) cout<<RD()%t<<" "; cout<<endl; cout<<q<<endl; while(q--){ cout<<RD()%t<<" "; } cout.flush(); exit(0); } signed main (){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); //mak(); //freopen("light.in","r",stdin); //freopen("light.out","w",stdout); cin>>n>>g>>r; // n=1e3,g=1e9,r=1e9; for(int i=1;i<=n+1;i++) cin>>d[i], // d[i]=RD(), s[i]=s[i-1]+d[i]; tot=g+r; bool sub=n>1000; if(sub){ for(int i=n;i>=1;i--){ // for(int i=0;i<tot;i++) // cout<<gt(i)<<" "; // cout<<endl; sft(d[i+1]); // for(int i=0;i<tot;i++) // cout<<gt(i)<<" "; // cout<<endl; // for(int i=0;i<tot;i++) // cout<<gt(i)<<" "; // cout<<endl; f[i]=calc(0,i,gt(0)); mod(g,tot-1,i); mat[i]=gt(0); // for(int i=0;i<tot;i++) // cout<<gt(i)<<" "; // cout<<endl; // cout<<endl; } // for(int i=1;i<=n;i++) // cout<<mat[i]<<" "; // cout<<endl; cin>>q; //q=0; while(q--){ int t; cin>>t; t+=d[1]; cout<<calc(t,1,gt(t))<<endl; } } else{ // freopen("light.ans","w",stdout); cin>>q; // q=1e3; // vector<int>E; while(q--){ int t=RD(); cin>>t; // E.push_back(t); for(int i=1;i<=n;i++){ t+=d[i]; // cout<<t<<" "; if(t%tot>=g) t=(t+tot-1)/tot*tot; // cout<<t<<endl; } cout<<t+d[n+1]<<endl; } cout.flush(); } cout.flush(); return 0; }


测评信息: