QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#514095#8322. 魔法手杖kymmykym0 306ms5252kbC++141.2kb2024-08-10 21:45:562024-08-10 21:45:56

Judging History

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

  • [2024-08-10 21:45:56]
  • 评测
  • 测评结果:0
  • 用时:306ms
  • 内存:5252kb
  • [2024-08-10 21:45:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=100005; 
int n,m,k;
int A[maxn],B[maxn];
bool on(int X, int bit){
	return X&(1<<bit);
}
int off(int X, int bit){
	X|=1<<bit;
	X^=1<<bit;
	return X;
}
int dpdp(int X, int Y, int bit, bool debt){
	if(bit == -1)return 0;
	if(debt==0){
		if(on(X,bit) && on(Y,bit)){
			return (1<<bit) + (dpdp(off(X,bit),off(Y,bit),bit-1,0));
		} 
		if(on(X,bit) && !on(Y,bit)){
			int c1=(1<<bit)-1;
			return dpdp(off(X,bit),Y,bit-1, 1);
		} else if(!on(X,bit) && on(Y,bit)){
			int res=(1<<(bit+1))-1;
			return res;
		} else{
			return (1<<bit) + dpdp(off(X,bit),off(Y,bit),bit-1,0);
		}
	} else{
		if(!on(Y,bit)){
			return Y + (1<<(bit+1))-1; // just fill everything
		} else{
			if(on(X,bit)){
				return (1<<(bit+1)) + dpdp(off(X,bit),off(Y,bit),bit-1,0);
			} else{
				return (1<<(bit+1)) + dpdp(off(X,bit),off(Y,bit),bit-1,1);
			}
		}
	}
	
}
void solve(){
	int n,m,k;cin>>n>>m>>k;
	--k;
	for(int i=1;i<=n;i++)cin>>A[i];
	for(int i=1;i<=n;i++)cin>>B[i];
	int X=-1,Y=-1;
	for(int i=1;i<=n;i++){
		if(B[i] == 2){
			X=A[i];
		} else{
			Y=A[i];
		}
	}
	cout<<dpdp(X,Y,k,0)<<"\n";
}
int32_t main(){
	int id,T;cin>>id>>T;
	while(T--)solve();
}

詳細信息


Pretests


Final Tests

Test #1:

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

input:

1 2
1 1 10
69
0
9 1000000000 10
244 710 380 144 439 863 870 166 346
495676227 842003627 148079269 750582321 584950601 767126829 909307499 254106473 942938842

output:

580
684

result:

wrong answer 1st lines differ - expected: '1092', found: '580'

Test #2:

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

input:

2 2
1 1 10
523
0
9 1000000000 10
848 862 206 186 563 318 692 557 937
922116005 577545690 363781833 81032507 443868714 352716275 50542823 305806582 28805127

output:

778
980

result:

wrong answer 1st lines differ - expected: '1546', found: '778'

Test #3:

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

input:

3 2
1 1 10
98
0
9 1000000000 10
329 357 633 469 110 721 457 238 51
40948203 144541423 719902898 403414385 625735025 473335146 107749900 238792543 449945390

output:

609
562

result:

wrong answer 1st lines differ - expected: '1121', found: '609'

Test #4:

score: 0
Wrong Answer
time: 154ms
memory: 5252kb

input:

4 5
100000 0 30
76630934 108936482 130420626 131855744 105346843 128458246 108243259 68059982 126654362 129080907 113416035 106976866 67840827 131702105 31856035 114313339 128664146 83795983 89307173 119627353 87072570 90008429 101830816 86771207 109365348 78483596 96660700 94183829 84341841 6114378...

output:

638981854
754993054
545359518
562924350
790687154

result:

wrong answer 1st lines differ - expected: '939540479', found: '638981854'

Test #5:

score: 0
Wrong Answer
time: 159ms
memory: 5156kb

input:

5 5
100000 0 30
76630412 108936989 130419821 131855908 105346921 128458123 108243250 68060024 126653456 129080620 113415939 106976648 67840659 131702589 31855988 114313916 128664271 83796359 89307559 119627595 87072119 90007889 101830798 86770759 109365415 78484075 96661493 94184047 84342493 6114315...

output:

638981406
1055934366
545359518
562924204
783871410

result:

wrong answer 1st lines differ - expected: '939540479', found: '638981406'

Test #6:

score: 0
Wrong Answer
time: 158ms
memory: 5164kb

input:

6 5
100000 0 30
76630333 108936734 130420608 131855493 105346592 128458438 108243159 68059640 126653892 129080993 113415838 106976338 67840970 131701923 31855999 114313236 128664302 83796315 89307977 119627172 87072644 90007888 101831307 86771011 109365285 78483904 96661399 94183858 84341903 6114386...

output:

638981760
1029719966
545359518
562924326
697363890

result:

wrong answer 1st lines differ - expected: '939540479', found: '638981760'

Test #7:

score: 0
Wrong Answer
time: 306ms
memory: 3616kb

input:

7 250000
2 1 16
40654 60936
1 2
2 1 5
29 18
1 2
2 1 9
367 278
1 2
2 1 6
32 40
1 2
2 1 28
211414711 120442951
1 2
2 1 9
440 62
1 2
2 1 2
2 2
1 2
2 1 6
60 1
1 2
2 1 1
0 0
1 2
2 1 16
39195 9530
1 2
2 1 19
260304 52003
1 2
2 1 12
1492 2878
1 2
2 1 22
2112709 2056045
1 2
2 1 30
840827142 778131799
1 2
2 ...

output:

57037
31
511
55
268435455
511
3
63
1
65535
524287
3539
4194303
1073741823
1008
268435455
1073741823
31
11702391
9094075
262143
31
131071
262143
4496
31091473
1
16777215
0
536870911
1015807
255
46328856
92
7
1023
6051001
528998770
3
246803
1
1
16383
2047
8388607
63
16252927
63
3972053
62709
25564183
...

result:

wrong answer 1st lines differ - expected: '55295', found: '57037'

Test #8:

score: 0
Wrong Answer
time: 292ms
memory: 3632kb

input:

8 250000
2 1 24
7245747 7751903
1 2
2 1 18
7301 21614
1 2
2 1 2
1 3
1 2
2 1 3
0 4
1 2
2 1 22
1946046 3459042
1 2
2 1 1
0 1
1 2
2 1 27
110608129 62075905
1 2
2 1 7
79 78
1 2
2 1 1
0 0
1 2
2 1 8
190 156
1 2
2 1 29
213608577 61390223
1 2
2 1 21
194242 1613306
1 2
2 1 8
46 195
1 2
2 1 12
2674 3172
1 2
2...

output:

16515071
253060
2
3
3145727
0
134217727
127
1
255
536870911
1242817
173
3697
1
92
490495
131071
131071
2097151
58195967
4194303
1793
43
3553286
2047
14
8388607
7
65535
13141
324155
1
30
2047
2047
16383
255
268435455
7
1959
33534953
32739558
1
15
34
60404
2097151
2047
14115520
127
7864319
63
3
511
26...

result:

wrong answer 59th lines differ - expected: '3519', found: '3572'

Test #9:

score: 0
Wrong Answer
time: 157ms
memory: 5092kb

input:

9 40003
100000 1 30
76630623 108936745 130419844 131856358 105346889 128458736 108243812 68059447 126654184 129080977 113416077 106976936 67840619 131702296 31855896 114313546 128664506 83796193 89307481 119627719 87072176 90007912 101831608 86771305 109366220 78484119 96661356 94183598 84341931 611...

output:

1049709150
1073741823
1073676287
1502
536870911
3255
496
8388607
675300594
32463846
11229
4095
1791
10
28919
255
2097151
7843296
0
7
7837709
65535
44907914
939524095
24792545
95
7717
446645098
536870911
1073741823
15
3670015
131071
1048575
8388607
262143
63
2047
4194937
81650945
134217727
196607
893...

result:

wrong answer 1st lines differ - expected: '939540479', found: '1049709150'

Test #10:

score: 0
Wrong Answer
time: 166ms
memory: 5248kb

input:

10 40003
100000 1 30
76630457 108937083 130420232 131855828 105346260 128458262 108242996 68059167 126653670 129080772 113416051 106976793 67840568 131702468 31855850 114313412 128664110 83796459 89307450 119627418 87071762 90007680 101831024 86771509 109365868 78483555 96661066 94183460 84342625 61...

output:

1049708984
1073741823
1073676287
60480681
2097151
67108863
3155155
129381658
433
8191
58
134217727
1857
41569662
52013361
6557
131071
4095
12142
1422
30
57648
1023
131071
2097151
14
149415025
524287
49399
28602
8302663
212
1025248
663675
129993
1
960284954
63
207916
15
511
263184795
15
524287
64
121...

result:

wrong answer 1st lines differ - expected: '939540479', found: '1049708984'

Test #11:

score: 0
Wrong Answer
time: 139ms
memory: 5168kb

input:

11 40003
100000 1 30
76630674 108936653 130420433 131856265 105346983 128458653 108243409 68059656 126653505 129080757 113415755 106976914 67840002 131701979 31855773 114313774 128664187 83796634 89307850 119627507 87071827 90007813 101831495 86771399 109365557 78483822 96660811 94184023 84342680 61...

output:

1073741823
1073741823
1073741823
63
127
1360
54051878
3
32767
10
4194303
2097151
2047
67108863
255
7340031
718565
356026509
6029311
6291455
3
13532
15
268435455
32
8388607
1073741823
7
8388607
32525861
10
15
511
1015807
2
359468184
31
63933171
15754
3
16777215
67108863
28671
127
6009046
1073741823
5...

result:

wrong answer 1st lines differ - expected: '939540479', found: '1073741823'

Test #12:

score: 0
Wrong Answer
time: 147ms
memory: 5224kb

input:

12 40003
100000 1 30
76630775 108937143 130420127 131855472 105346114 128458369 108243185 68060064 126653745 129080952 113415931 106976535 67841016 131701837 31855974 114313669 128664055 83796306 89307860 119626895 87072131 90008292 101831649 86771064 109366112 78484048 96660693 94184079 84342338 61...

output:

1073741823
1073694622
1073741823
990
432
6887
131071
12471
131071
4
65535
16777215
3145727
282
0
122590
131071
4095
14118083
23
982397
2391507
36
4194303
16383
536870911
511
15743
524287
67108863
5631
16777215
1073741823
8191
180
15
134217727
129337772
1073741823
1
4194303
65535
511
536870911
229159...

result:

wrong answer 1st lines differ - expected: '939540479', found: '1073741823'

Test #13:

score: 0
Wrong Answer
time: 140ms
memory: 5156kb

input:

13 40003
100000 1 30
76630774 108936584 130420001 131856305 105347060 128457982 108243169 68059620 126654022 129081029 113415335 106976790 67840471 131702040 31855824 114314232 128663903 83796420 89307827 119626984 87072029 90008558 101830939 86770995 109365419 78483800 96660514 94183753 84342755 61...

output:

1073741823
1073694622
1073741823
15308
33554431
262143
5320634
112106309
2097151
2097151
350966295
1048575
4194303
1028422157
61316327
11
511
511
282
15601
112
524287
196607
131071
2097151
2
39
58059956
15
32767
5
6271450
64992947
7644064
15
4431
676399
4095
110552615
2097151
4095
1036
255
33554431
...

result:

wrong answer 1st lines differ - expected: '939540479', found: '1073741823'

Test #14:

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

input:

14 5
100 1000000000 30
13132 1189 129473 100435 99142 27988 125913 84108 88618 104500 18510 127909 33713 41539 73168 52981 93666 111173 97215 18318 116125 48796 66468 68341 66995 8141 6453 78522 5137 102161 79767 83305 55735 35923 57672 40415 26124 3517 89580 103805 63333 70578 15006 115257 25327 11...

output:

536875357
670040148
537497258
537001315
973078527

result:

wrong answer 1st lines differ - expected: '1073641471', found: '536875357'

Test #15:

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

input:

15 5
100 1000000000 30
13147 1100 129952 101117 98742 27859 125802 84826 88433 104546 18804 127522 33108 41885 72848 52261 94114 110852 97024 17835 116004 48702 65612 68427 67541 7813 6415 78436 5289 102296 78964 83467 56256 36720 58141 39956 25783 3977 89405 104251 63057 69881 14546 115008 24936 10...

output:

536875139
1040187476
537497153
537001323
807403519

result:

wrong answer 1st lines differ - expected: '1073641471', found: '536875139'

Test #16:

score: 0
Wrong Answer
time: 23ms
memory: 3700kb

input:

16 4003
10000 1000000000 60
6301301488220013 13036910415217886 3587708952967093 9679001900905121 15370074903700843 10699351669343223 3693263165367499 11069887286230748 16712579672850495 7401912839403587 2739985286259605 4571772340856038 7048969239142713 1894459710006182 17112800883496323 12320029364...

output:

11637232337722555
747668041113875
292211831388362
8367504
3056427392
3957435545
954458620
971247
9626
1432444
267115034
2946815374
4200082509
95210974
958300204
203615045
1956508140
1484108
3088271286
5
4164590498
3416
233553965
295261020
4006748524
720166108
-357404015
1548853254
3344738143
3059676...

result:

wrong answer 1st lines differ - expected: '1134974176306659327', found: '11637232337722555'

Test #17:

score: 0
Wrong Answer
time: 33ms
memory: 3696kb

input:

17 4003
10000 1000000000 60
6301301819534654 13036910822653667 3587709968963537 9679000983663529 15370074961371554 10699347928378657 3693263473368908 11069883997526525 16712580951412763 7401916234416503 2739986911540418 4571770484223398 7048969495053322 1894461412350279 17112799936179837 12320030978...

output:

11637231803957525
455197948125459
292212310073148
14415430
-693497124
30802226
3439026945
845147043
1937747236
-705504331
31
1449879
2752
4
0
1648360858
5227405
766703256
2471353021
27
2072357622
23424
1114686
-24256586
3090380599
25
5950080
-847206885
166658
2
2190997160
1123185130
3897914240
14532...

result:

wrong answer 1st lines differ - expected: '1134973076795031551', found: '11637231803957525'

Test #18:

score: 0
Wrong Answer
time: 31ms
memory: 3780kb

input:

18 4003
10000 1000000000 60
6301305150188370 13036910274580735 3587707298181505 9679004703165232 15370075141428877 10699349494581236 3693260766091278 11069885717856260 16712580184551432 7401916423007610 2739984412836669 4571773004118082 7048970479824295 1894458866748282 17112803260092779 12320029000...

output:

11637233749936995
730075855069459
292211741621041
233196
739915
3491168120
1912
1289729232
353709
3211529238
4
2895441789
73823705
360424103
777583925
-522152198
14002257
-1494910582
745099
1307747442
1363708369
513
125355
118822632
3948893673
1732794942
-1253519447
1494
1442520100
24694203
-7196667...

result:

wrong answer 1st lines differ - expected: '1134977474841542655', found: '11637233749936995'

Test #19:

score: 0
Time Limit Exceeded

input:

19 62501
100000 1000000000 120
1154838249421518343773531773357597778 1154838249421518343773531773357629327 1154838249421518343773531773357650307 1154838249421518343773531773357651709 1154838249421518343773531773357625821 1154838249421518343773531773357648391 1154838249421518343773531773357628650 115...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #20:

score: 0
Time Limit Exceeded

input:

20 62501
100000 1000000000 120
323632031276481459143358069001495634 323632031276481459143358069001527183 323632031276481459143358069001548163 323632031276481459143358069001549565 323632031276481459143358069001523677 323632031276481459143358069001546247 323632031276481459143358069001526506 3236320312...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #21:

score: 0
Time Limit Exceeded

input:

21 62501
100000 1000000000 120
94863733210630102424008628084424216 134857169996406520360367913319523910 161452665267901932764497978184577026 163229916633468866695669655916793917 130413130894076501442669761804067887 159024080878679252370015542440688101 133998758779238309221865949392709341 84253191505...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #22:

score: 0
Time Limit Exceeded

input:

22 120001
100000 1000000000 120
47471234275189825886337730002101330 47471234275189825886337730002132879 47471234275189825886337730002153859 47471234275189825886337730002155261 47471234275189825886337730002129373 47471234275189825886337730002151943 47471234275189825886337730002132202 4747123427518982...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #23:

score: 0
Time Limit Exceeded

input:

23 120001
100000 1000000000 120
10384594543745281933157089286344285 10384595087221325583432181750603761 10384596344313448100419024142756824 10384597896452402824418716086599406 10384599662161038685053136018241571 10384600136159512396111755729028709 10384601958291386084902861505361244 1038460344973912...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #24:

score: 0
Time Limit Exceeded

input:

24 120001
100000 1000000000 120
10384594585679242355840829886289379 10384595083750076569134324633632941 10384596423425537641166720528386677 10384598270636404608178558554968102 10384598723408000881156593449465505 10384600392016296777984789088889743 10384602014485619490959986853506329 1038460298717050...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result:


Test #25:

score: 0
Time Limit Exceeded

input:

25 120001
100000 1000000000 120
10384594059032377855972206804990515 10384595922446112233978399250497752 10384596677646074836565734489994716 10384597585175584397302672981127521 10384599121981302637859909713499899 10384600188980133483790411300324684 10384601157708131158985167495674683 1038460244379676...

output:

8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
127
63
31
15
7
3
1
0
-2147483649
1073741823
536870911
268435455
134217727
67108863
33554431
16777215
8388607
4194303
2097151
1048575
524287
262143
131071
65535
32767
16383
8191
4095
2047
1023
511
255
1...

result: