QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372052#3013. XOR SequencesInfinityNS#AC ✓5ms4704kbC++141.4kb2024-03-30 20:13:272024-03-30 20:13:29

Judging History

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

  • [2024-03-30 20:13:29]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:4704kb
  • [2024-03-30 20:13:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int mod=1e9+7;
int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}

const int N=(1<<17)+50;
int p[N],L[N],R[N],cnt[N],po[N];
bool was[N];

int ans=1;
void Solve(int l,int r,int lvl){
	bool allEq=true;
	for(int i=l;i<=r;i++)if(p[i]!=p[l])allEq=false;
	if(allEq){
		if(was[p[l]])ans=0;
		was[p[l]]=true;
		ans=mul(ans,po[lvl]);
	}else{
		int mid=l+r>>1;
		bool ok=true;
		for(int i=l;i<=mid;i++){
			if(p[i]!=p[mid+i-l+1])ok=false;
		}
		if(ok){
			Solve(l,mid,lvl-1);
			ans=mul(ans,2);
		}else{
			Solve(l,mid,lvl-1);
			Solve(mid+1,r,lvl-1);
		}
	}
}
int main(){
	int m,n;
	scanf("%i %i",&m,&n);
	for(int i=1;i<=n;i++)L[i]=(1<<m)+1,R[i]=-1;
	for(int i=0;i<(1<<m);i++){
		scanf("%i",&p[i]);
	}
	/*for(int j=m-1;j>=0;j--){
		bool ok=true;
		for(int i=0;i<(1<<m);i++){
			if(p[i]!=p[i^(1<<j)])ok=false;
		}
		if(ok){
			ans=mul(ans,2);
			int ptr=0;
			for(int i=0;i<(1<<m);i++){
				if(i>>j&1){
					p[ptr++]=p[i];
				}
			}
			m--;
		}
	}
	for(int i=0;i<(1<<m);i++){
		L[p[i]]=min(L[p[i]],i);
		R[p[i]]=max(R[p[i]],i);
		cnt[p[i]]++;
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]!=R[i]-L[i]+1)ans=0;
	}*/
	po[0]=1;
	for(int i=1;i<=m;i++)po[i]=mul(po[i-1],2);
	Solve(0,(1<<m)-1,m);
	printf("%i\n",ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3932kb

input:

4 12
2
2
3
6
1
12
1
12
9
7
5
5
4
8
10
11

output:

8

result:

ok answer is 8

Test #2:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

4 5
2
2
2
2
5
1
5
1
4
4
3
3
4
4
3
3

output:

64

result:

ok answer is 64

Test #3:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

4 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

16

result:

ok answer is 16

Test #4:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

0 1
1

output:

1

result:

ok answer is 1

Test #5:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

1 1
1
1

output:

2

result:

ok answer is 2

Test #6:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

1 2
2
1

output:

1

result:

ok answer is 1

Test #7:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

2 3
2
2
3
1

output:

2

result:

ok answer is 2

Test #8:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

2 3
2
1
2
3

output:

0

result:

ok answer is 0

Test #9:

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

input:

16 2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2552
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2551
2550
2550
2550
2550
2550
2550
2550
2550
2550
2550
25...

output:

596575534

result:

ok answer is 596575534

Test #10:

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

input:

16 647
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
190
190
190
190
190
190
190
190
149
149
149
149
149
149
149
149
190
190
190
190
190
190
190
190
149
1...

output:

883211652

result:

ok answer is 883211652

Test #11:

score: 0
Accepted
time: 3ms
memory: 4076kb

input:

16 4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

974740338

result:

ok answer is 974740338

Test #12:

score: 0
Accepted
time: 3ms
memory: 4152kb

input:

16 16
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
...

output:

978747134

result:

ok answer is 978747134

Test #13:

score: 0
Accepted
time: 2ms
memory: 4060kb

input:

16 16
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

output:

487761806

result:

ok answer is 487761806

Test #14:

score: 0
Accepted
time: 3ms
memory: 4060kb

input:

16 17
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

output:

489373567

result:

ok answer is 489373567

Test #15:

score: 0
Accepted
time: 0ms
memory: 4652kb

input:

16 52361
26988
51822
45167
17373
49212
14325
34575
52354
35631
50239
36790
52350
8802
46009
50010
47588
42797
46395
42797
46395
40654
20412
48888
48888
26581
34567
22029
22029
19970
45614
18366
18366
17163
26564
45082
26166
15479
33436
329
329
33854
26248
37775
6536
52323
52323
4089
30570
24208
2420...

output:

117465194

result:

ok answer is 117465194

Test #16:

score: 0
Accepted
time: 5ms
memory: 4636kb

input:

16 65536
55473
32701
13511
38981
9512
17597
22203
30263
44926
35075
44124
18851
31048
64346
27158
20745
40676
16101
7773
14416
26240
65515
21677
8375
63022
29250
53479
31055
20771
4954
26110
17283
61220
53404
33552
60001
36161
40692
9321
7700
41378
44316
14018
44886
31791
32758
23113
34455
30974
141...

output:

1

result:

ok answer is 1

Test #17:

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

input:

16 256
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44
44...

output:

409643880

result:

ok answer is 409643880

Test #18:

score: 0
Accepted
time: 2ms
memory: 4024kb

input:

16 1935
539
539
539
539
1057
1057
1057
1057
539
539
539
539
1057
1057
1057
1057
664
664
664
664
664
664
664
664
664
664
664
664
664
664
664
664
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
1027
996
996
996
996
996
996
996
996
996
996
996
996
996
996
996
996
1351
1351
13...

output:

127536394

result:

ok answer is 127536394

Test #19:

score: 0
Accepted
time: 3ms
memory: 4180kb

input:

16 195
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114
74
74
74
74
74
74
74
74
33
33
33
33
33
33
33
33
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
5...

output:

39724215

result:

ok answer is 39724215

Test #20:

score: 0
Accepted
time: 0ms
memory: 4192kb

input:

16 783
665
665
665
665
665
665
665
665
413
413
413
413
413
413
413
413
665
665
665
665
665
665
665
665
413
413
413
413
413
413
413
413
665
665
665
665
665
665
665
665
413
413
413
413
413
413
413
413
665
665
665
665
665
665
665
665
413
413
413
413
413
413
413
413
665
665
665
665
665
665
665
665
413
4...

output:

436717605

result:

ok answer is 436717605

Test #21:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

3 6
5
3
2
6
1
1
4
4

output:

4

result:

ok answer is 4

Test #22:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

5 13
7
7
7
7
7
7
7
7
2
11
6
4
5
5
1
1
10
10
10
10
10
10
10
10
13
13
8
9
12
3
12
3

output:

1024

result:

ok answer is 1024

Test #23:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

6 13
1
1
2
2
7
7
7
7
9
9
13
13
8
8
8
8
3
3
11
11
3
3
11
11
6
6
6
6
6
6
6
6
10
4
10
4
12
12
12
12
10
4
10
4
12
12
12
12
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5

output:

4194304

result:

ok answer is 4194304

Test #24:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

7 68
8
8
8
8
64
64
64
64
37
48
56
66
11
11
49
49
68
68
68
68
59
10
59
10
13
13
60
60
14
14
53
53
18
18
6
6
23
19
23
19
42
21
67
65
50
22
44
45
31
32
31
32
61
61
39
39
3
3
5
36
54
63
7
7
25
17
46
40
29
29
29
29
35
35
55
38
43
9
57
34
12
12
30
30
16
16
16
16
58
58
58
58
15
27
24
51
62
62
2
2
62
62
2
2...

output:

46480318

result:

ok answer is 46480318

Test #25:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

8 6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

output:

73741817

result:

ok answer is 73741817

Test #26:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

9 49
5
5
5
5
5
5
5
5
47
47
47
47
47
47
47
47
5
5
5
5
5
5
5
5
47
47
47
47
47
47
47
47
46
46
46
46
4
4
4
4
46
46
46
46
4
4
4
4
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
30
30
30
30
30
30
30
30
33
33
33
33
33
33
33
33
39
39
39
39
39
39
39
39
20
20
20
20
35
35
35
35
18
18
18
18
17
17
17
17
18
18
1...

output:

896465609

result:

ok answer is 896465609

Test #27:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

10 64
19
14
7
12
22
25
31
46
8
50
56
24
48
49
11
60
2
53
45
4
5
63
29
61
39
62
32
6
28
33
52
64
54
59
55
1
16
37
47
3
30
20
21
58
36
43
26
51
41
9
18
10
27
38
44
40
23
57
42
15
13
34
35
17
19
14
7
12
22
25
31
46
8
50
56
24
48
49
11
60
2
53
45
4
5
63
29
61
39
62
32
6
28
33
52
64
54
59
55
1
16
37
47
3...

output:

16

result:

ok answer is 16

Test #28:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

11 762
439
439
651
236
207
207
90
649
1
382
1
382
27
27
27
27
36
36
36
36
248
142
729
582
688
688
83
83
688
688
83
83
208
208
569
569
24
260
10
10
525
525
486
696
16
276
367
262
519
58
519
58
204
204
204
204
664
153
19
430
127
127
349
420
174
174
174
174
601
601
442
442
757
757
757
757
757
757
757
7...

output:

39724215

result:

ok answer is 39724215

Test #29:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

12 1479
183
183
118
118
437
437
578
765
305
305
305
305
305
305
305
305
716
716
716
716
716
716
716
716
1188
1188
1188
1188
620
620
1106
540
1328
1328
1328
1328
1328
1328
1328
1328
1126
1126
403
403
1126
1126
403
403
269
269
224
224
433
433
433
433
1466
1466
1466
1466
1466
1466
1466
1466
1237
166
12...

output:

937814008

result:

ok answer is 937814008

Test #30:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

13 396
389
389
389
389
389
389
389
389
389
389
389
389
389
389
389
389
75
75
75
75
75
75
75
75
395
395
395
395
395
395
395
395
389
389
389
389
389
389
389
389
389
389
389
389
389
389
389
389
75
75
75
75
75
75
75
75
395
395
395
395
395
395
395
395
239
239
239
239
239
239
239
239
239
239
239
239
239
2...

output:

842859955

result:

ok answer is 842859955

Test #31:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

14 4951
2865
2865
2865
2865
2865
2865
2865
2865
2271
2271
2271
2271
2271
2271
2271
2271
3682
3682
3682
3682
310
310
656
656
1218
1218
1218
1218
1218
1218
1218
1218
67
67
67
67
2345
2345
4614
4614
72
276
72
276
2121
2121
2847
3018
4280
4280
2450
2450
4652
4652
4652
4652
3208
3208
312
312
3034
3034
30...

output:

498151463

result:

ok answer is 498151463

Test #32:

score: 0
Accepted
time: 3ms
memory: 4284kb

input:

15 27203
9513
9513
26575
24670
27095
14488
18493
1040
18109
6885
18889
4812
12731
12731
2427
3882
20214
12403
17994
17994
17880
23915
7134
15931
27009
27009
20406
20406
16694
16694
16164
7244
18615
10090
21903
21903
23518
23518
8447
23227
22417
858
14463
14463
19410
14063
12699
13934
1496
1496
22226...

output:

684550435

result:

ok answer is 684550435

Test #33:

score: 0
Accepted
time: 2ms
memory: 4588kb

input:

16 58916
16289
53146
58914
22416
38195
49329
2376
2376
2596
6941
53789
46252
33403
33403
35014
50680
16209
44858
873
43569
13338
34650
24614
37528
12158
57357
29646
27545
29383
10178
57019
18987
46024
14513
1199
34183
1653
1653
27502
776
19498
36063
19498
36063
34249
39460
6267
49764
6825
42107
3279...

output:

181973755

result:

ok answer is 181973755

Test #34:

score: 0
Accepted
time: 0ms
memory: 4136kb

input:

16 2048
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
1861
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
649
527
...

output:

446371492

result:

ok answer is 446371492

Test #35:

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

input:

16 2584
1868
1868
1413
2446
1868
1868
1413
2446
105
74
105
74
1989
1989
1424
2167
1868
1868
1413
2446
1868
1868
1413
2446
105
74
105
74
1989
1989
1424
2167
1529
2098
1529
2098
1806
1806
793
1093
1529
2098
1529
2098
1806
1806
793
1093
555
555
1709
1888
555
555
1709
1888
1820
2278
1820
2278
767
767
22...

output:

724522059

result:

ok answer is 724522059

Test #36:

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

input:

16 31
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
...

output:

779974913

result:

ok answer is 779974913

Test #37:

score: 0
Accepted
time: 5ms
memory: 4284kb

input:

16 25600
4587
12833
7039
15676
12191
735
10896
10254
17899
22150
25241
8654
23349
18461
726
938
24924
12214
17647
23699
15766
17721
16327
3519
755
25586
3216
18566
7128
6794
9627
17252
19892
22874
2733
2413
791
10866
12752
14471
20687
605
1189
23100
12393
12085
24005
21427
24874
4767
17405
3436
7787...

output:

134217728

result:

ok answer is 134217728

Test #38:

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

input:

16 6542
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
3302
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
6242
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
3481
5393
5393
5393
5393
5393
5393
5393
5393
5393
5393
53...

output:

520728849

result:

ok answer is 520728849

Test #39:

score: 0
Accepted
time: 5ms
memory: 4704kb

input:

16 58992
50748
45232
54713
49171
40606
58987
28176
12464
38684
31394
38359
35220
54187
40949
38972
38972
53664
53664
13380
37776
7646
23835
721
11748
29239
46653
52378
32244
30354
58965
36680
13873
18035
31906
21608
58648
1757
3150
51689
51689
24129
51356
6183
55534
25960
5494
10008
37370
44953
2601...

output:

563345299

result:

ok answer is 563345299

Test #40:

score: 0
Accepted
time: 2ms
memory: 4112kb

input:

16 12870
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
12721
127...

output:

949866298

result:

ok answer is 949866298

Test #41:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

3 4
1
2
3
3
1
2
4
4

output:

0

result:

ok answer is 0