UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#148410#711. 子段与子段yhz097ms2048kbC++780b2022-07-02 11:11:172022-07-02 11:11:19

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=1e5+8;
int q,Qj[N],n,Qo[N],a[N*2];
inline int Xor(int X,int Y)
{
	return X^Y;
}
int main()
{
	//freopen("1.in","r",stdin);
	ios::sync_with_stdio(0);
	cin>>n>>q;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		if(i%2==0)
		{
			Qo[i/2]=Xor(Qo[i/2-1],a[i]);
		//	cout<<Qo[i/2]<<" ";
		}
		else
		{
			Qj[i/2+1]=Xor(Qj[i/2],a[i]);
		//	cout<<Qj[i/2+1]<<" ";
		}
	}
	//cout<<"\n";
	int Left,Right;
	while(q--)
	{
		int ans;
		cin>>Left>>Right;
		if((Right-Left)%2==1)
		{
			cout<<0<<"\n";
		}
		else
		{
			if(Right%2)
			{
				ans=(Qj[Right/2+1]^Qo[Left/2]);
			}
			else
			{
				ans=Xor(Qo[Right/2],Qo[Left/2-1]);
			}
			cout<<ans<<"\n";
		}
	}
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1260kb

input:

85 69
548813502 592844616 715189365 844265744 602763370 857945620 544883177 847251738 423654797 6235...

output:

0
951879720
728206291
0
619164920
0
0
0
42265468
0
0
573645098
500954349
0
25763698
42788921
9993589...

result:

wrong answer 2nd lines differ - expected: '644820523', found: '951879720'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 1264kb

input:

423 290
978570924 699479278 116201910 297436951 767023703 813797820 411820142 396505739 675439077 88...

output:

0
0
0
0
707992900
270991261
0
0
0
0
0
0
657995439
908298291
0
46055450
42160380
861393780
260244656
...

result:

wrong answer 5th lines differ - expected: '15173667', found: '707992900'

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 1264kb

input:

378 454
133439431 354506059 96803952 657019776 343391726 652308955 591026897 821718566 659176476 402...

output:

686352458
970029727
404404026
0
141880656
0
334018354
32865220
0
564300695
0
986664612
590518644
0
6...

result:

wrong answer 1st lines differ - expected: '48497967', found: '686352458'

Test #4:

score: 0
Wrong Answer
time: 4ms
memory: 1284kb

input:

3037 4378
417539200 908733438 781581726 735740086 693747026 265930487 916340332 145435607 259377388 ...

output:

901634558
0
0
0
0
0
0
745108608
0
0
0
0
696299071
784805072
0
897727105
142066897
602709946
0
0
1394...

result:

wrong answer 8th lines differ - expected: '474285889', found: '745108608'

Test #5:

score: 0
Wrong Answer
time: 13ms
memory: 1300kb

input:

4999 5000
967530414 172693304 359512489 997981817 404660934 192181283 270965714 700750919 191655676 ...

output:

233505749
0
0
0
393354817
574346565
0
554062144
265770971
482676417
846454227
0
0
762965773
0
0
0
64...

result:

wrong answer 5th lines differ - expected: '873105880', found: '393354817'

Test #6:

score: 0
Wrong Answer
time: 8ms
memory: 1300kb

input:

5000 3974
675120207 299084507 569184751 260345141 958619695 108295541 251585378 273711740 673245537 ...

output:

0
941965468
0
0
303081797
0
89848341
953769662
0
0
0
480289863
748731858
0
914889001
0
0
886263764
0...

result:

wrong answer 5th lines differ - expected: '38177163', found: '303081797'

Test #7:

score: 0
Time Limit Exceeded

input:

158743 198243
856178259 883873487 991830273 443193787 903900695 503226693 85996783 71587981 60920822...

output:

0
65170460
0
0
0
706651795
0
0
0
206153405
0
0
0
53213663
838714099
0
778678276
434351573
631835520
...

result:


Test #8:

score: 0
Wrong Answer
time: 70ms
memory: 2048kb

input:

100000 100000
721098242 656500803 61409187 805548033 814529341 519590328 15569063 100649386 15183930...

output:

0
0
526344193
1047144946
988681469
455141424
41277027
76194859
743998539
0
241745279
1065051659
0
0
...

result:

wrong answer 4th lines differ - expected: '1006669799', found: '1047144946'

Test #9:

score: 0
Time Limit Exceeded

input:

200000 200000
842131068 673388219 498522264 748121531 385261331 610188593 827387456 885226316 758584...

output:

0
275549935
0
396120338
1034543190
0
0
807381121
0
0
644596552
0
514828825
160929506
0
0
0
418645642...

result:


Test #10:

score: 0
Time Limit Exceeded

input:

200000 200000
185214635 632101741 433544469 492815454 77281985 916988410 769930803 929871128 6818313...

output:

0
394243017
0
0
0
0
0
0
0
57870252
877958836
945344844
0
0
710925290
0
924709630
776084302
0
0
0
338...

result: