QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#646528 | #7449. rgxsxrs | DaiRuiChen007 | 0 | 386ms | 18148kb | C++17 | 3.1kb | 2024-10-17 00:18:54 | 2024-10-17 00:18:54 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline void chkmin(int &x,const int &y) { x=x<y?x:y; }
inline void chkmax(int &x,const int &y) { x=x>y?x:y; }
const int MAXN=5e5+5,inf=2e9,MOD=(1<<20)-1;
const int MAXS=32785,B=32;
const int H=6,pw[]={1,32,1024,32768,1048576,33554432};
inline int vblk(int x) { return upper_bound(pw,pw+H,x)-pw-1; }
int n,m,K,a[MAXN],b[MAXN],lp[MAXN],rp[MAXN],bel[MAXN],id[MAXS];
array<int,H> mn[MAXS],mx[MAXS],tg[MAXS],cnt[MAXS];
array<ll,H> sum[MAXS];
inline void blk_psu(const int &o,const int &p) {
mn[p].fill(inf),mx[p].fill(0),cnt[p].fill(0),sum[p].fill(0);
for(int i=lp[o];i<=rp[o];++i) {
chkmin(mn[p][b[i]],a[i]);
chkmax(mx[p][b[i]],a[i]);
sum[p][b[i]]+=a[i],++cnt[p][b[i]];
}
}
inline void psu(const int &p) {
for(int x=0;x<H;++x) {
mn[p][x]=min(mn[p<<1][x],mn[p<<1|1][x]);
mx[p][x]=max(mx[p<<1][x],mx[p<<1|1][x]);
sum[p][x]=sum[p<<1][x]+sum[p<<1|1][x];
cnt[p][x]=cnt[p<<1][x]+cnt[p<<1|1][x];
}
}
inline void blk_psd(const int &o,const int &p) {
for(int i=lp[o];i<=rp[o];++i) if(a[i]>tg[p][b[i]]) a[i]-=tg[p][b[i]];
tg[p].fill(0);
}
inline void adt(const int &p,const int &x,const int &k) {
if(!cnt[p][x]) return ;
tg[p][x]+=k,mn[p][x]-=k,mx[p][x]-=k,sum[p][x]-=1ll*cnt[p][x]*k;
}
inline void psd(const int &p) {
for(int x=0;x<H;++x) if(tg[p][x]) {
adt(p<<1,x,tg[p][x]),adt(p<<1|1,x,tg[p][x]),tg[p][x]=0;
}
}
void init(int l=1,int r=K,int p=1) {
if(l==r) return id[p]=l,blk_psu(id[p],p);
int mid=(l+r)>>1;
init(l,mid,p<<1),init(mid+1,r,p<<1|1);
psu(p);
}
int ul,ur,cl,cr,qmn,qmx; ll qsum;
inline void blk_qry(const int &o) {
for(int i=max(lp[o],ul);i<=ur&&i<=rp[o];++i) qsum+=a[i],chkmin(qmn,a[i]),chkmax(qmx,a[i]);
}
void qry(int l=1,int r=K,int p=1) {
if(ul<=lp[l]&&rp[r]<=ur) {
for(int x=0;x<H;++x) qsum+=sum[p][x],chkmin(qmn,mn[p][x]),chkmax(qmx,mx[p][x]);
return ;
}
if(id[p]) return blk_psd(id[p],p),blk_qry(id[p]);
psd(p);
int mid=(l+r)>>1;
if(cl<=mid) qry(l,mid,p<<1);
if(mid<cr) qry(mid+1,r,p<<1|1);
}
inline void blk_upd(const int &k,const int &o) {
for(int i=max(lp[o],ul);i<=ur&&i<=rp[o];++i) if(a[i]>k) a[i]-=k,b[i]=vblk(a[i]);
}
void upd(const int &k,int l=1,int r=K,int p=1) {
bool fg=1;
for(int x=0;x<H;++x) fg&=mx[p][x]<=k;
if(fg) return ;
if(ul<=lp[l]&&rp[r]<=ur) {
fg=1;
for(int x=vblk(k);x<H;++x) fg&=mn[p][x]-k>=pw[x];
if(fg) {
for(int x=vblk(k);x<H;++x) adt(p,x,k);
return ;
}
}
if(id[p]) return blk_psd(id[p],p),blk_upd(k,id[p]),blk_psu(id[p],p);
psd(p);
int mid=(l+r)>>1;
if(cl<=mid) upd(k,l,mid,p<<1);
if(mid<cr) upd(k,mid+1,r,p<<1|1);
psu(p);
}
signed main() {
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=n;++i) cin>>a[i],b[i]=vblk(a[i]);
K=(n-1)/B+1;
for(int i=1;i<=K;++i) {
lp[i]=(i-1)*B+1,rp[i]=min(i*B,n);
fill(bel+lp[i],bel+rp[i]+1,i);
}
init();
int lst=0;
for(int op,k;m--;) {
cin>>op>>ul>>ur,ul^=lst,ur^=lst;
if(op==1) cin>>k,k^=lst,upd(k);
else {
qmn=inf,qmx=qsum=0,qry();
cout<<qsum<<" "<<qmn<<" "<<qmx<<"\n";
lst=qsum&MOD;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 16008kb
input:
1000 1000 935816535 513713699 701239859 881761843 312245068 749043434 112422339 4851733 369182510 741607986 336173081 76013815 91837056 23042507 28754006 935721035 332487169 739344582 280604892 549629633 428486579 693745524 772744523 736620619 596867287 553364838 842666116 620926490 350404590 972861...
output:
0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 ...
result:
wrong answer 1st numbers differ - expected: '265016378473', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 123ms
memory: 16740kb
input:
200000 200000 10 7 6 1 5 5 10 1 9 4 7 1 5 4 8 9 5 7 10 2 10 3 3 5 5 2 1 4 10 5 7 2 6 1 3 1 6 4 7 5 3 1 3 2 9 5 4 10 8 3 10 4 4 8 5 4 6 10 4 10 9 6 7 4 6 7 7 6 2 6 6 10 10 6 8 8 9 4 6 3 3 9 8 1 8 5 8 2 7 3 1 10 5 10 1 5 8 5 6 6 7 9 7 3 5 8 4 4 3 2 9 3 10 2 5 4 2 2 6 3 3 5 8 4 2 1 2 9 2 3 6 3 8 9 4 10...
output:
0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 ...
result:
wrong answer 1st numbers differ - expected: '8548', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 110ms
memory: 16928kb
input:
200000 200000 615 736 846 534 658 429 631 720 898 583 797 295 303 336 449 358 57 338 954 414 330 212 171 200 403 553 308 20 805 249 767 291 545 196 324 928 439 197 20 601 737 748 817 858 816 130 403 858 813 936 771 242 833 863 978 260 357 856 954 89 673 733 364 473 903 445 823 894 49 747 382 56 309 ...
output:
0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 ...
result:
wrong answer 1st numbers differ - expected: '4143168', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 121ms
memory: 16768kb
input:
200000 200000 78066 141247 11068 105207 26127 179253 104948 145839 150954 60877 67556 61673 69638 150806 127596 162902 125410 38242 97645 20582 193537 139906 114184 129867 126626 85640 91551 19445 134855 85251 22162 3798 122992 38278 131907 96159 153440 94561 185234 15296 76886 108452 70560 77355 14...
output:
0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 ...
result:
wrong answer 1st numbers differ - expected: '9335629761', found: '0'
Subtask #5:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 386ms
memory: 18148kb
input:
500000 500000 56 22353719 15918 54 13 1 389 7 809 2204 75911688 4218278 36 7205 93542078 506 4761175 102646343 48 65900 10 228 2 292994 26348644 6 19339 148 704 232124395 19307 52070 8964343 7430314 42755 115 869 32485365 252183868 481162087 852632 38758 2945883 279412 15012 82 33076951 1537 6954898...
output:
0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 0 2000000000 0 ...
result:
wrong answer 1st numbers differ - expected: '106593480756', found: '0'