QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470666#5022. 【模板】线段树DaiRuiChen0070 4ms15796kbC++171.7kb2024-07-10 15:45:002024-07-10 15:45:00

Judging History

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

  • [2024-07-10 15:45:00]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:15796kb
  • [2024-07-10 15:45:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=1<<18,B=1<<9;
int a[MAXN],w[MAXN],bel[MAXN],lp[MAXN],rp[MAXN],len[MAXN];
//w[i]: a[ed[x]] after oper i-lp[x] times
vector <int> tag[MAXN];
void init(int x) { //build block x
	int n=len[x],*f=w+lp[x];
	for(int i=0;i<n;++i) f[i]=a[rp[x]-i];
	for(int k=1;k<n;k<<=1) for(int i=0;i<n;++i) if(i&k) f[i]^=f[i^k];
}
void psd(int x) { //pushdown block x
	vector <int> &g=tag[x];
	int n=len[x],m=g.size(),*f=a+lp[x];
	for(int k=1;k<n&&k<=m;k<<=1) if(m&k) {
		for(int i=n-1;i>=k;--i) f[i]^=f[i-k];
	}
	reverse(g.begin(),g.end());
	for(int k=1;k<m;k<<=1) for(int i=0;i<m;++i) if(i&k) g[i^k]^=g[i];
	for(int i=0;i<n&&i<m;++i) f[i]^=g[i];
	g.clear();
}
int qed(int x) { //qry a[rp[x]]
	int n=len[x];
	if((int)tag[x].size()>=n) psd(x),init(x);
	return w[lp[x]+tag[x].size()];
}
int qry(int i) {
	psd(bel[i]),init(bel[i]);
	return a[i];
}
void opr(int l,int r) {
	if(bel[l]==bel[r]) {
		psd(bel[l]);
		for(int i=r;i>bel[l];--i) a[i]^=a[i-1];
		return init(bel[l]);
	}
	psd(bel[r]);
	for(int i=r;i>lp[bel[r]];--i) a[i]^=a[i-1];
	a[lp[bel[r]]]^=qed(bel[r]-1);
	init(bel[r]);
	for(int i=bel[r]-1;i>=bel[l]+1;++i) tag[i].push_back(qed(i-1));
	psd(bel[l]);
	for(int i=rp[bel[l]];i>l;--i) a[i]^=a[i-1];
	init(bel[l]);
}
signed main() {
	ios::sync_with_stdio(false);
	int _,n,m;
	cin>>_>>n>>m;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;rp[i-1]<n;++i)  {
		lp[i]=rp[i-1]+1,rp[i]=min(n,lp[i]+B);
		fill(bel+lp[i],bel+rp[i]+1,i);
	}
	for(int op,l,r,x;m--;) {
		cin>>op;
		if(op==1) cin>>l>>r,opr(l,r);
		else cin>>x,cout<<qry(x)<<"\n";
	}
	for(int i=1;i<=bel[n];++i) psd(i),init(i);
	for(int i=1;i<=n;++i) cout<<a[i]<<"\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 8
Accepted
time: 2ms
memory: 12520kb

input:

1
6 6
1 1 5 1 9 4
2 5
1 2 5
2 4
1 3 6
2 6
1 1 6

output:

9
4
12
1
0
5
4
12
0

result:

ok 9 numbers

Test #2:

score: 0
Accepted
time: 4ms
memory: 15248kb

input:

1
999 997
898798734 979577086 45974352 1013270193 1053191143 533594258 372426673 947830633 122319874 368651315 866424479 109724831 427664962 558099346 764830489 326451620 322471751 525780385 746941281 670254345 586958579 979544209 743892216 436404384 291681381 979530194 998929567 367716728 909076993...

output:

1015342581
962986689
965094083
871356796
835210392
172023195
63088572
606096781
569607283
436055720
154605892
663158209
154605892
776365236
281312240
62398687
182713417
604764772
816533315
793514230
325061861
806973284
91749226
283750235
198953311
170342298
432592070
809908556
683302450
40932811
669...

result:

ok 1996 numbers

Test #3:

score: -8
Wrong Answer
time: 3ms
memory: 15796kb

input:

1
999 997
89872218 906651903 120274311 490547919 291584020 755757065 24942887 707247173 763024744 68250332 114193028 999245166 140381610 171802205 399965713 299821903 907998064 906075056 427270276 335420206 708713870 492555323 359637714 197212814 35225369 1011322274 912003632 633998134 1026276199 85...

output:

89872218
906651903
880411170
740065207
573573041
959553351
639093196
541531303
419485514
624405871
563316430
829830056
777593718
757772020
917046379
860085107
174972134
383449625
225483608
1065382555
712743755
750356567
426398951
912403510
930307942
1050439158
99460861
942490985
103204023
432607399
...

result:

wrong answer 2nd numbers differ - expected: '860962725', found: '906651903'

Subtask #2:

score: 0
Runtime Error

Test #6:

score: 0
Runtime Error

input:

2
249998 99999
1048488450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0
0

result:


Subtask #3:

score: 0
Runtime Error

Test #10:

score: 0
Runtime Error

input:

3
250000 99999
1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0 0 1 1...

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #14:

score: 0
Runtime Error

input:

4
249996 99997
309331355 195839266 912372930 57974187 363345291 954954162 650621300 389049294 821214285 263720748 231045308 844370953 768579771 664766522 681320982 124177317 32442094 297873605 743179832 1073656106 443742270 235746807 1054294813 974443618 422427461 307448375 1018255356 20105813 36821...

output:


result:


Subtask #5:

score: 0
Runtime Error

Test #18:

score: 0
Runtime Error

input:

5
249997 99997
860563869 428592873 58576739 761578583 47999879 294581118 988847649 569566599 640106250 440172702 178219106 966598261 763325707 846927552 877923116 145156535 246778542 25949847 507939778 116507169 555239769 259969305 328955819 171606729 535970481 121608060 4437163 370976515 713807003 ...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #5:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%