QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#646275#7449. rgxsxrsDaiRuiChen0070 2596ms16716kbC++172.8kb2024-10-16 22:02:042024-10-16 22:02:05

Judging History

你现在查看的是最新测评结果

  • [2024-10-16 22:02:05]
  • 评测
  • 测评结果:0
  • 用时:2596ms
  • 内存:16716kb
  • [2024-10-16 22:02:04]
  • 提交

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,B=32,H=6,pw[H]={1,32,1024,32768,1048576,33554432},MAXS=32785;
inline int vblk(int x) { return upper_bound(pw,pw+6,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];
array<ll,H> sum[MAXS];
void blk_psu(int o,int p) {
	mn[p].fill(inf),mx[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];
	}
}
void psu(int p) {
	if(id[p]) return blk_psu(id[p],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];
	}
}
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);
}
void blk_psd(int o,int p) {
	for(int i=lp[o];i<=rp[o];++i) if(a[i]>tg[p][b[i]]) a[i]-=tg[p][b[i]],assert(a[i]>=pw[b[i]]);
	tg[p].fill(0);
}
void psd(int p) {
	if(id[p]) return blk_psd(id[p],p);
	for(int x=0;x<H;++x) if(tg[p][x]) {
		tg[p<<1][x]+=tg[p][x],tg[p<<1|1][x]+=tg[p][x],tg[p][x]=0;
	}
}
int qmn,qmx; ll qsum;
void blk_qry(int l,int r,int o) {
	for(int i=max(lp[o],l);i<=r&&i<=rp[o];++i) qsum+=a[i],chkmin(qmn,a[i]),chkmax(qmx,a[i]);
}
void qry(int ul,int ur,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 ;
	}
	psd(p);
	if(id[p]) return blk_qry(ul,ur,id[p]);
	int mid=(l+r)>>1;
	if(bel[ul]<=mid) qry(ul,ur,l,mid,p<<1);
	if(mid<bel[ur]) qry(ul,ur,mid+1,r,p<<1|1);
}
void blk_upd(int l,int r,int k,int o) {
	for(int i=max(lp[o],l);i<=r&&i<=rp[o];++i) if(a[i]>k) a[i]-=k,b[i]=vblk(a[i]);
}
void upd(int ul,int ur,int k,int l=1,int r=K,int p=1) {
	if(ul<=lp[l]&&rp[r]<=ur) {
		bool flg=1;
		for(int x=vblk(k);x<H;++x) flg&=mn[p][x]-k>=pw[x];
		if(flg) {
			for(int x=vblk(k);x<H;++x) tg[p][x]+=k;
			return ;
		}
	}
	psd(p);
	if(id[p]) return blk_upd(ul,ur,k,id[p]),blk_psu(id[p],p);
	int mid=(l+r)>>1;
	if(bel[ul]<=mid) upd(ul,ur,k,l,mid,p<<1);
	if(mid<bel[ur]) upd(ul,ur,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,l,r,k;m--;) {
		cin>>op>>l>>r,l^=lst,r^=lst;
		if(op==1) cin>>k,k^=lst,upd(l,r,k);
		else {
			qmn=inf,qmx=qsum=0,qry(l,r);
			cout<<qsum<<" "<<qmn<<" "<<qmx<<"\n";
			lst=qsum&((1<<20)-1);
		}
	}
	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: 0ms
memory: 15884kb

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:

265016378473 746807 999055631
666065535 666065535 666065535
271006237166 746807 999055631
244146031651 726339 992039812
15823858743 7712227 991422034
1807891893 93288403 840436769
17240518274 746807 968670509
110636754727 726339 817084515
58475591074 746807 806807028
0 2000000000 0
0 2000000000 0
0 ...

result:

wrong answer 25th numbers differ - expected: '57343541330', found: '58475591074'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 2596ms
memory: 16716kb

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:

8548 1 10
358083 1 10
372560 1 10
368886 1 10
0 2000000000 0
132190 1 7
15187 1 10
91726 1 10
0 2000000000 0
0 2000000000 0
0 2000000000 0
27827 1 10
71531 1 10
0 2000000000 0
0 2000000000 0
102160 1 10
0 2000000000 0
0 2000000000 0
0 2000000000 0
185252 1 10
0 2000000000 0
405989 1 10
0 2000000000 ...

result:

wrong answer 7th numbers differ - expected: '371696', found: '372560'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 2559ms
memory: 16660kb

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:

4143168 1 1000
8707838 1 1000
47831397 1 1000
22409353 1 1000
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 ...

result:

wrong answer 7th numbers differ - expected: '47796901', found: '47831397'

Subtask #4:

score: 0
Time Limit Exceeded

Test #8:

score: 0
Time Limit Exceeded

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:

9335629761 8 199997
291062233 15 145210
2757513812 2 114001
457932161 15 145210
2990172835 2 113932
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
26253...

result:


Subtask #5:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

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:

106593480756 1 984003850
3714830493496 1 992522749
0 2000000000 0
1782669852454 1 977708457
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 ...

result: