QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567768#6330. XOR ReachableUESTC_DECAYALI#AC ✓267ms219092kbC++202.1kb2024-09-16 13:50:232024-09-16 13:50:27

Judging History

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

  • [2024-09-16 13:50:27]
  • 评测
  • 测评结果:AC
  • 用时:267ms
  • 内存:219092kb
  • [2024-09-16 13:50:23]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<vector>
#include<utility>
#define RI register int
#define CI const int&
using namespace std;
typedef pair <int,int> pi;
const int N=100005,P=30;
struct Data
{
	int x,y,szy;
	inline Data(CI X=0,CI Y=0,CI SZY=0)
	{
		x=X; y=Y; szy=SZY;
	}
}stk[N*P]; int n,m,k,x[N],y[N],z[N],q,p,top,fa[N],sz[N]; long long ret,ans[N];
inline int getfa(CI x)
{
	return fa[x]!=x?getfa(fa[x]):x;
}
inline long long C2(CI x)
{
	return 1LL*x*(x-1)/2LL;
}
inline void merge(int x,int y)
{
	x=getfa(x); y=getfa(y); if (x==y) return;
	if (sz[x]>sz[y]) swap(x,y); stk[++top]=Data(x,y,sz[y]);
	fa[x]=y; ret-=C2(sz[x]); ret-=C2(sz[y]); sz[y]+=sz[x]; ret+=C2(sz[y]);
}
inline void revoke(CI tmp)
{
	while (top>tmp)
	{
		int x=stk[top].x,y=stk[top].y,szy=stk[top].szy;
		--top; fa[x]=x; ret-=C2(sz[y]); sz[y]=szy; ret+=C2(sz[x]); ret+=C2(sz[y]);
	}
}
class Trie
{
	private:
		int ch[N*P][2],tot; vector <int> id[N*P]; vector <pi> v[N*P];
	public:
		inline Trie() { tot=1; }
		inline void insert(CI x,CI num,CI now=1,CI y=P-1)
		{
			if (!~y) return id[now].push_back(num); int d=(x>>y)&1;
			if (!ch[now][d]) ch[now][d]=++tot; insert(x,num,ch[now][d],y-1);
		}
		inline void apply(CI now,const pi& it)
		{
			v[now].push_back(it);
		}
		inline void solve(CI k,CI w,const pi& it,CI now=1,CI y=P-1)
		{
			if (!~y||!now) return; int d=(k>>y)&1;
			if (d) apply(ch[now][(w>>y)&1],it);
			solve(k,w,it,ch[now][d^((w>>y)&1)],y-1);
		}
		inline void travel(CI now=1,CI y=P-1)
		{
			if (!now) return; int tmp=top; for (auto [x,y]:v[now]) merge(x,y);
			if (!~y)
			{
				for (int it:id[now]) ans[it]=ret; return revoke(tmp);
			}
			travel(ch[now][0],y-1); travel(ch[now][1],y-1); revoke(tmp);
		}
}T;
int main()
{
	//freopen("CODE.in","r",stdin); freopen("CODE.out","w",stdout);
	RI i; for (scanf("%d%d%d",&n,&m,&k),i=1;i<=m;++i)
	scanf("%d%d%d",&x[i],&y[i],&z[i]);
	for (scanf("%d",&q),i=1;i<=q;++i) scanf("%d",&p),T.insert(p,i);
	for (i=1;i<=m;++i) T.solve(k,z[i],pi(x[i],y[i]));
	for (i=1;i<=n;++i) fa[i]=i,sz[i]=1;
	for (T.travel(),i=1;i<=q;++i) printf("%lld\n",ans[i]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 12ms
memory: 183500kb

input:

4 5 5
1 2 17
1 3 4
2 3 20
2 4 3
3 4 5
4
0
7
16
167

output:

2
6
3
0

result:

ok 4 number(s): "2 6 3 0"

Test #2:

score: 0
Accepted
time: 16ms
memory: 183052kb

input:

9 13 488888932
2 7 771479959
3 8 783850182
5 7 430673756
6 8 350738034
4 9 400768807
2 3 83653266
1 2 829786563
5 8 357613791
7 9 579696618
3 7 423191200
3 5 867380255
1 9 907715012
6 9 1033650694
8
498260055
144262908
117665696
848664012
983408133
32610599
478007408
134182829

output:

16
7
5
13
13
16
16
5

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 187ms
memory: 212540kb

input:

446 99235 764320136
1 2 467639025
1 39 240791819
1 197 320023434
1 391 968343602
1 116 841220144
1 345 697806443
1 409 489643820
1 339 733516272
1 89 560099922
1 431 722346703
1 433 246809211
1 344 769002876
1 234 597076758
1 178 505730391
1 75 826728597
1 74 14756981
1 63 280238017
1 288 638627144
...

output:

99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 168ms
memory: 211148kb

input:

443 100000 587238331
315 322 662401332
43 315 536337643
315 404 1008807430
140 315 116993236
315 349 456757176
315 421 208121145
222 315 165949374
315 359 652820576
128 315 366321131
219 315 385302776
279 315 758612678
315 369 524221824
315 418 405097334
315 344 159069559
114 315 1020799146
36 315 4...

output:

97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
97903
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 175ms
memory: 204780kb

input:

446 99235 319005349
63 98 45774435
98 419 537824294
55 98 970456100
98 295 177258162
98 148 503686739
98 355 952389094
98 110 672181282
98 113 718706403
98 222 193797576
79 98 367361921
8 98 82995994
13 98 401334976
98 427 695043885
98 366 595065071
98 161 581346320
98 128 792799449
98 178 566239903...

output:

99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
99235
...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 169ms
memory: 206984kb

input:

442 100000 203918091
334 408 765591331
65 334 841282977
34 334 774464729
135 334 790897433
118 334 220810832
334 383 37271884
334 357 975552850
334 424 634443624
330 334 811688196
321 334 48524877
280 334 40028159
251 334 193460453
198 334 689798118
146 334 734763167
326 334 899636923
89 334 1067215...

output:

97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
97461
...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 173ms
memory: 212576kb

input:

100000 99999 131080539
55331 77587 680598826
74630 82197 773435840
9490 88468 37670073
8680 59512 493328849
38978 96144 563550542
41963 66970 73513321
1494 85761 799508674
11271 31250 1022044318
39311 99039 1054195469
26320 50975 6951442
3560 84539 467850296
32918 83458 159835633
9576 55206 85302837...

output:

15096
14956
15004
14891
15137
14885
15410
15089
15502
15087
15083
14905
15143
15137
15104
15163
15143
15111
15090
15190
15187
15156
14992
15150
15100
15082
14919
14952
15047
15120
15117
14992
14990
15087
15411
14916
15092
15133
15139
15130
14910
15184
15132
15122
15105
15210
14939
15173
14829
15455
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 238ms
memory: 213328kb

input:

99248 100000 880016512
9609 60188 1029518407
67457 77348 128441060
8850 51205 291062482
9624 19858 873440302
20602 31653 646044502
60977 74199 403271514
77359 98694 422310541
18100 53413 641772941
31582 84949 147530174
20254 46153 615653756
78917 86611 850029098
1309 67868 867784476
96643 98988 2712...

output:

5879363
7746507
9770252
7878863
4967006
5004278
4977178
4462464
4171192
4889527
9480939
4983900
5303714
6557680
6810967
13375644
5057196
7210193
6272443
6998946
6557952
4869510
4462624
5179208
5002020
8220896
4489581
7017776
9264220
4838591
8881657
5606801
6164119
6939146
4997590
6840650
5164401
554...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 194ms
memory: 206872kb

input:

100000 99999 780251002
27269 79999 468071962
21739 82319 682546466
8544 67158 927078439
41968 89207 892254915
48895 55914 193589771
811 49765 490891662
16872 46729 638680406
17867 44058 1070155835
10241 98888 957737438
2201 46513 627847434
21108 88949 186267330
51802 94981 1008817703
20063 25385 676...

output:

851649
896751
856223
866092
859330
890327
903448
864667
873749
844234
887957
862832
833840
905858
833512
864850
890697
875940
877015
889585
919407
899670
879354
835757
889043
891332
909448
910965
855701
898062
868582
884660
898820
827552
858726
865812
887067
893299
882047
902597
880316
836660
868968...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 209ms
memory: 208436kb

input:

99806 100000 506098337
11316 29606 1053169611
432 77576 188106174
60898 63565 97507616
2948 56878 759293962
57945 69338 892503621
46617 98850 666735935
8904 20788 54696907
42854 49896 442509177
55987 59613 499913803
2227 46042 620057838
1275 36485 557003410
67033 68875 81080762
22626 80910 375900469...

output:

142524
143221
141571
141415
141524
142903
143150
143834
142172
143779
142631
141438
143293
143212
143554
142975
142308
143115
143789
145039
145108
143357
142820
142972
143680
143486
142794
143012
141832
141238
143252
141992
143985
143054
143789
143443
143073
141272
143134
141352
142940
143778
143199...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 214ms
memory: 218800kb

input:

100000 99999 880261730
49362 60034 719788352
49362 82351 832947612
79673 82351 727350251
79673 98801 931190441
83274 98801 44235181
21205 83274 530387154
19108 21205 173298793
19108 91835 42875759
27763 91835 658199843
27698 27763 541513285
27698 69932 660043688
51737 69932 28343715
51737 64682 7092...

output:

463133
455785
451937
457179
465888
460719
456177
451132
460492
449885
456575
457673
455205
452446
453629
450871
454195
452710
452761
454742
448762
462880
454503
450564
457018
457173
446406
455921
452926
449909
455853
452542
457657
449390
451219
455492
460180
454384
451712
451310
457955
450590
453810...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 236ms
memory: 215980kb

input:

99280 100000 664494301
16664 29169 599202135
16664 23186 47757770
23186 47063 53266202
47063 85549 1072849246
63153 85549 506433067
63153 80308 580031399
51234 80308 348201803
51234 73193 964438190
73193 84836 959143019
13056 84836 425988976
13056 24417 378109570
332 24417 407996769
332 15544 127696...

output:

169861
168547
170195
167590
167947
171070
169400
169439
168358
168772
169763
168179
170227
169694
170376
170362
170270
168542
168205
170671
170992
167808
170218
169766
169488
169765
169621
169346
170434
169658
168462
167814
168089
169909
169162
169769
169559
169763
171592
170886
168176
170407
170956...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 190ms
memory: 208720kb

input:

100000 99999 387919793
43583 94512 58705781
10271 43583 170607984
10271 32855 106243875
16854 32855 410273584
3517 16854 890474326
3517 30975 1001361623
20910 30975 1002711314
20910 35013 187670767
32382 35013 239178409
18343 32382 649107746
18343 98413 178223318
98413 99691 35024867
52041 99691 870...

output:

55965
57403
55280
57482
55332
57469
55577
56542
55629
55614
57389
56900
56227
55407
56343
56292
55715
55744
55868
55483
56329
56020
55483
56524
55703
57237
55332
55946
56013
55305
56717
56599
56629
57509
57456
56122
57308
56593
55645
55568
57383
55493
55754
55628
55604
55622
55635
57476
56916
55462
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 192ms
memory: 207908kb

input:

99215 100000 802557726
18718 91317 755608910
18718 63717 531481378
30529 63717 642051004
30529 98706 599162314
42379 98706 1033145474
12300 42379 475403483
12300 12338 704395523
12338 98081 711250138
57669 98081 696479725
3890 57669 159898669
3890 64697 759770705
64697 85928 251213884
11945 85928 50...

output:

325883
325574
325225
327438
326494
328594
325193
325522
326677
325193
326907
327836
326189
325885
325339
326122
325379
327013
327616
326596
326962
324792
325751
325773
325810
326287
327825
325773
327896
326283
327310
325931
326309
326164
324663
326225
324826
325760
327847
325563
326191
325762
325419...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 218ms
memory: 213432kb

input:

100000 99999 402174476
58524 93393 539162433
24909 58524 573965219
58524 88865 99051060
58524 97907 525721613
28122 58524 520563970
18857 58524 305560747
492 58524 1044154487
58524 84138 410295914
4924 58524 880315377
58524 79039 763682384
58524 88879 903645824
58524 84125 286649901
58524 98278 1032...

output:

698949966
700146910
701756916
705846378
701831845
702281503
705808806
702056656
696820446
701906778
701307426
702656328
703631341
701831845
701157628
700371451
701569611
696745785
702056656
699884991
702918765
705696096
696633801
698763036
699361300
701831845
700221753
699697936
706184571
701831845
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 173ms
memory: 214536kb

input:

99105 100000 921189055
27602 89467 871564070
73578 89467 892334196
33998 89467 730765033
42525 89467 490770744
10543 89467 48350959
23444 89467 648340211
63556 89467 691268936
37607 89467 427726217
32870 89467 435269802
72115 89467 999718290
6379 89467 905774706
15973 89467 135638767
21262 89467 507...

output:

3624792969
3624537532
3643719678
3643634305
3618665147
3626070240
3637831762
3625899923
3623005143
3633482900
3636722982
3624878103
3623686166
3634676446
3624878103
3641159125
3633056681
3642695343
3624111830
3635529104
3643805044
3628795853
3634676451
3624537530
3637917064
3633482900
3643463575
361...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 183ms
memory: 205400kb

input:

100000 99999 679882689
58387 94702 419316719
58387 74538 804700023
13639 58387 516717865
16355 58387 648000582
58387 85987 676587546
58387 92832 904327018
43945 58387 30482169
38016 58387 1000125878
52242 58387 619949646
19644 58387 464625256
58387 91871 902831480
45768 58387 337695617
38323 58387 4...

output:

2009114355
2016474265
2014379128
2011967895
2009304528
2031744385
1979557581
1988691711
2001451546
1998289371
2009114355
2028749451
2027857770
2003793165
2003033571
2011714165
2012792628
1989196275
1996014153
2017363440
1978802595
2017172886
1988250270
2014886940
2007403203
2016855316
2018443416
200...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 185ms
memory: 209336kb

input:

99696 100000 433484222
15535 74820 193053771
49557 74820 196842880
62381 74820 79212906
31117 74820 833959008
70718 74820 649262218
56860 74820 246344682
8631 74820 169957827
2310 74820 732900575
74820 99284 739555015
3447 74820 475010097
3388 74820 969377946
2388 74820 807590871
22132 74820 6319663...

output:

817231837
807155976
817353130
805148295
818283320
823672609
801700936
816181034
803423686
808241162
821522883
825662602
805469360
799980048
802101417
819052136
825581331
822252666
816746769
818687912
815696277
820469325
819294995
801300576
800980347
819537890
817717054
819497405
804305809
821198640
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 203ms
memory: 209916kb

input:

100000 100000 1062032266
22211 48279 1060026482
22632 32390 842951551
10268 83993 951617844
91592 98922 845778447
77149 98853 763688613
56053 70280 244874876
22196 95617 372895509
66924 83740 45318731
70188 73104 119729078
35836 80723 344470318
95564 95679 904924735
14097 52566 262568441
28651 61121...

output:

3127582096
3131062861
3128689474
3134941482
3131379418
3131616891
3131854344
3132883264
3132408375
3130509068
3129401273
3132804102
3132329149
3135970889
3124498358
3130746315
3130983793
3132804078
3130350781
3130113326
3129243176
3132883098
3135099896
3122364576
3127344806
3130508993
3135812628
313...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 215ms
memory: 211152kb

input:

99672 99625 1054752250
28289 45884 626685976
4717 47248 290819812
28968 44157 637912934
38939 97492 767973161
10545 96579 399966947
4703 57028 196340670
71905 85157 481531139
23842 25551 376399599
50355 71552 202579985
12815 27787 958119286
53610 83405 976519803
3487 65277 1038562227
8992 45160 2391...

output:

3074346209
3072307904
3071915787
3073405056
3071602289
3078268101
3064474173
3084390900
3075051889
3073640515
3072464530
3074659640
3078817056
3083055898
3077640209
3077012677
3080543807
3078346554
3072621341
3071602335
3078346262
3073562137
3080543654
3076855662
3080386874
3072386010
3069878213
307...

result:

ok 99138 numbers

Test #21:

score: 0
Accepted
time: 198ms
memory: 210720kb

input:

99628 99396 492500659
46329 97186 745686192
16150 85274 107579031
7130 80654 6325319
2286 62141 498958770
10800 69611 477586530
948 53379 170814235
7607 51421 942502255
55520 73939 170098739
15348 45463 341123290
1751 38059 711970002
91398 94258 146749262
48069 87794 589000897
46795 71115 386715121
...

output:

687296
580675
478093
502923
648657
706361
465786
516267
471330
480159
478562
459914
695621
458335
485458
678024
628524
539316
473246
466375
500790
632511
538974
527869
621100
463319
565062
462236
500956
529041
629276
556694
505979
463414
582871
450617
538511
555928
484537
537287
646089
536225
452939...

result:

ok 99010 numbers

Test #22:

score: 0
Accepted
time: 172ms
memory: 206592kb

input:

99302 99853 197249381
49172 50946 637696889
83639 83821 511956365
9956 71695 944889669
5721 63910 35668351
68079 81135 1053490245
13095 81514 422668799
15919 18518 255609468
27120 52506 424576273
2870 82057 5692084
56922 85467 1011012440
74100 74854 1017906700
45588 55972 990996195
159 46033 7872695...

output:

29223
29124
29166
28840
28923
28636
28414
29187
29160
28616
28848
28565
29168
28547
28679
29239
28952
29035
28721
29303
29344
28781
28599
28902
28630
28439
29468
29125
29449
29376
28583
29481
29387
28319
28826
29177
28315
29409
28408
29185
28430
28950
28337
28940
28421
28925
28492
29265
28674
28405
...

result:

ok 99117 numbers

Test #23:

score: 0
Accepted
time: 198ms
memory: 205196kb

input:

99011 99031 607400868
48014 76110 754021063
2616 81083 681648181
22861 56121 932401683
83596 88114 607083940
32183 59290 574984702
41837 80837 484173564
40268 91957 326604154
49089 84512 570662918
81089 89238 541773961
23557 41516 933269272
34605 77588 265694051
34399 39330 178362416
16631 75841 351...

output:

243204777
249917140
213968950
235612524
232511777
255320885
222406817
244456738
219028301
242751709
248013415
246512065
237083944
221012419
245095698
227948834
243422906
233830866
249645759
228566869
249535016
219232957
250123995
238597477
252317982
239948766
222662230
252884277
239387661
251754179
...

result:

ok 99644 numbers

Test #24:

score: 0
Accepted
time: 174ms
memory: 207732kb

input:

99040 99859 299514887
14702 55423 320674359
19009 78598 906042375
19070 47924 1025775797
18615 65340 240120670
63838 83312 626941391
52145 79941 841285862
27251 91162 616183829
11793 66085 22122559
53548 77376 868446884
20525 78692 596695526
7151 50845 719623592
14510 40114 372868681
54517 69409 574...

output:

63835
63712
63705
63490
62736
62438
65706
64446
64037
62930
65714
64374
65007
65217
61508
64871
64869
64994
62765
66051
62641
61698
64796
63759
62801
62959
64019
65900
63646
62880
64569
62429
64350
64358
62590
63755
64988
61736
62469
63029
65864
64526
62726
63389
63523
62502
65201
65000
63950
62563
...

result:

ok 99757 numbers

Test #25:

score: 0
Accepted
time: 191ms
memory: 209732kb

input:

99889 99805 752076266
9528 68587 887213446
13301 26312 583081741
72271 81654 905609237
6555 23605 297507861
5703 91420 413923311
35199 68640 960922631
2181 62181 405070130
23010 69118 277065506
26620 96673 10075904
74806 97866 262232793
15667 58255 871128648
30827 81359 272250173
11724 56792 8975201...

output:

1312794820
1303894099
1280210251
1306755316
1284666150
1306344913
1305987507
1306653570
1300066138
1319101700
1286845510
1318233584
1300577885
1278136847
1280969167
1300681811
1281981232
1286744595
1296499711
1280414157
1279047373
1308853172
1277130658
1299813614
1282184482
1321109404
1299304538
132...

result:

ok 99696 numbers

Test #26:

score: 0
Accepted
time: 177ms
memory: 208588kb

input:

99258 99262 56019112
66965 95107 978064361
35115 69073 301582582
2675 9305 1027544309
15594 59091 581186820
6695 78180 709218053
37745 64040 251971250
6528 41160 641637561
63165 65678 912097197
10706 52741 913650679
12170 41733 668598040
72501 77687 995907155
42305 95353 8653820
14947 20299 45076413...

output:

5655
5888
5698
5767
5840
5773
5652
5823
5557
5827
5850
5725
5847
5628
5805
5822
5820
5805
5662
5859
5811
5911
5823
5883
5746
5662
5792
5855
5771
5751
5695
5779
5813
5668
5765
5754
5723
5709
5624
5693
5841
5626
5768
5741
5793
5865
5791
5754
5754
5893
5716
5784
5927
5870
5702
5673
5805
5790
5656
5639
...

result:

ok 99953 numbers

Test #27:

score: 0
Accepted
time: 227ms
memory: 212636kb

input:

99140 99097 737534996
19449 24765 536026893
7909 19620 188338802
5541 37064 161805
33807 59256 380484600
16939 40003 453558181
19174 63860 519402672
52537 75690 283335353
4255 27365 895272933
12461 55224 1041724805
44819 60427 436643691
39738 85475 787089381
69284 81496 871830721
31522 50402 6571961...

output:

1198175772
1189782243
1185389165
1189630297
1183491028
1163780151
1194514084
1189585771
1170203410
1188074020
1187680223
1190708922
1184859409
1190459455
1187147343
1201757947
1189288425
1190168464
1183247898
1193195064
1197686357
1176352233
1199203816
1200435105
1183150588
1188068512
1184516727
119...

result:

ok 99688 numbers

Test #28:

score: 0
Accepted
time: 204ms
memory: 207344kb

input:

99788 99502 276157280
20989 33380 580403845
37377 68909 34318010
54685 57378 988117
65058 99474 496512484
9890 16464 934683098
22413 78273 440779516
27372 86900 198152156
60239 64839 162109117
60860 67889 977225714
49384 68253 159646378
24468 73459 27668779
42628 45138 637535004
4991 29338 218630943...

output:

51470
52635
53525
51536
52544
53005
52742
53292
52427
53518
52755
52855
52658
51745
52539
51825
52519
51457
51380
52169
51152
52556
53225
53132
51387
51679
53185
52523
52495
51382
51140
51495
51660
51509
52517
51712
52567
53132
53021
51498
52574
51573
51348
51920
52565
52990
53073
51703
51411
51950
...

result:

ok 99205 numbers

Test #29:

score: 0
Accepted
time: 117ms
memory: 198852kb

input:

99727 100000 0
8048 39782 0
18422 18785 0
26908 35045 0
82687 86306 0
32907 44739 0
67703 82954 0
41964 73171 0
22914 78976 0
21310 31871 0
52664 94128 0
66225 70141 0
4738 66402 0
63535 82871 0
3899 36335 0
3665 48864 0
15138 59325 0
68303 91234 0
20219 29778 0
2618 45656 0
69726 89274 0
4785 29646...

output:

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
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99380 numbers

Test #30:

score: 0
Accepted
time: 267ms
memory: 219092kb

input:

99802 100000 1073741823
55112 99461 872247848
5239 13029 226631874
59010 75468 167120402
2530 99496 410389429
12778 95838 289552862
49010 95610 613010188
94861 99101 195464886
18975 34167 203072659
34837 70971 791148245
40397 45864 595052125
1082 26181 858239960
54896 76124 207145325
25041 52988 405...

output:

4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
4980169701
498...

result:

ok 99593 numbers

Test #31:

score: 0
Accepted
time: 138ms
memory: 198200kb

input:

99217 100000 0
12817 22546 0
20962 63373 0
53803 95439 0
15835 29915 0
72357 83267 0
11314 86740 0
2087 51205 0
25328 26809 0
8306 70660 0
20506 51748 0
57052 96232 0
28207 73424 0
20745 54909 0
51494 60202 0
15832 66033 0
13080 41377 0
61283 92214 0
47840 48749 0
15515 31768 0
80786 85706 0
50626 7...

output:

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
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99185 numbers

Test #32:

score: 0
Accepted
time: 266ms
memory: 218520kb

input:

99873 100000 1073741823
30961 38713 675237584
15634 99725 423671507
33690 66492 744089684
50422 89984 872482740
16952 23398 1038199073
23182 85461 550782386
10125 80535 557267488
36511 50092 633701698
40696 79736 580587538
37659 92577 923360161
14171 69307 267288185
11889 54911 453208669
82026 93278...

output:

4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
4987258128
498...

result:

ok 99038 numbers

Test #33:

score: 0
Accepted
time: 20ms
memory: 185456kb

input:

4960 4962 254286595
1121 3437 641432041
1916 2083 126344705
481 3495 1021118842
2113 4093 477804094
54 4735 311662827
893 1941 904983379
1377 4858 100551993
3643 4562 492935552
2126 4073 607199100
3215 4014 601042077
429 706 382195982
932 4518 981081968
1206 1970 374141539
799 2895 44081380
1243 489...

output:

2381
2352
2102
1833
2367
1818
2342
2115
1948
2329
2063
2328
1930
2071
2432
2039
2271
2092
1907
2024
2105
2024
2230
2343
2146
2041
2107
1901
2390
2100
2072
2342
2095
2095
2354
1898
2105
2133
2107
1980
2100
1904
2034
2416
2343
2313
2326
2351
2101
2309
2327
2281
2325
1910
2110
2116
2373
2419
1904
2333
...

result:

ok 4998 numbers

Test #34:

score: 0
Accepted
time: 20ms
memory: 185216kb

input:

4952 4974 1000565632
432 3991 491341112
113 4629 48465821
813 4402 800073221
1513 2163 155896300
3116 3939 311174320
1693 3323 275893307
309 3273 563047707
4345 4743 1069068691
4249 4406 798258282
3004 3456 866795560
1996 2812 680522188
1218 1535 912324073
660 4236 243097944
672 4351 816876175
363 3...

output:

6865936
7059920
7044875
7082445
7052297
6992536
7041102
7011538
7199480
6981618
6973761
7067385
7138963
7071053
6973748
6985096
7059847
7014839
6984989
6981280
6925762
7022333
7123894
7127653
6955098
7290839
7082529
6981319
6851169
7011268
7041011
7105043
6858548
7336712
6981280
7222511
6966265
7157...

result:

ok 4960 numbers

Test #35:

score: 0
Accepted
time: 28ms
memory: 183876kb

input:

4971 4980 400782308
1616 3841 189209007
74 2052 392591275
2104 4796 94888775
2020 3526 937951696
240 2424 341012217
1891 2429 490137001
1481 4858 229415696
10 3799 819269348
2222 4942 121486344
148 1993 311847898
2898 3700 144529816
677 2010 902185714
959 973 558301520
4006 4473 882860313
3010 4813 ...

output:

8146
7423
7415
8295
8192
7022
7325
8148
8359
7148
8315
7731
8210
8630
7444
8170
7809
8049
8026
6968
8552
7014
6990
7002
7647
8155
7779
6902
7182
8204
8445
8196
6860
7227
7787
8511
8376
7430
8382
6942
8269
7822
7140
7886
8185
8636
7380
8034
7418
7437
8176
7026
7016
7748
6990
8269
8655
7818
7442
7811
...

result:

ok 4966 numbers

Test #36:

score: 0
Accepted
time: 20ms
memory: 184568kb

input:

4994 4982 1024292189
2573 4258 457442262
4440 4482 1038417468
1388 3111 851373434
1433 4862 637795992
1615 4821 403867093
902 1871 432568365
1267 2261 805592924
2604 4694 733582343
872 3558 632554236
1353 3202 609710355
314 3032 1005076687
1625 3225 985126731
81 4464 55934572
3956 4386 454075229
292...

output:

7256565
7329127
7367487
7359869
7294737
7378981
7417425
7398211
7386664
7402056
7310046
7382839
7271865
7313915
7264186
7402048
7268103
7325371
7264254
7440534
7483037
7367515
7290923
7375148
7467571
7298561
7298667
7421287
7287118
7275766
7252760
7432861
7321520
7287141
7367515
7325372
7291002
7398...

result:

ok 4968 numbers

Test #37:

score: 0
Accepted
time: 28ms
memory: 184764kb

input:

4983 4952 226356464
150 4699 899173296
3251 3354 573286489
3860 4896 94997104
2816 3079 916719694
1029 3782 570959088
2855 4118 135577934
1101 2347 453963574
2219 2793 929076041
3936 4692 581702855
1857 3103 772769666
4165 4683 47196064
207 1030 906635961
1000 2331 610969623
707 3911 656415421
2784 ...

output:

1796
1936
1854
2045
1841
1862
1928
1666
1813
1603
1827
1615
1793
1895
1928
1691
1644
1603
1831
1878
1908
1874
1896
2029
1875
2199
2040
1936
1981
1900
1674
1843
1867
2161
1753
1647
2005
2009
1659
1690
1676
1805
1891
1777
1947
1650
2057
2215
1785
1801
1904
1855
1903
1726
1902
1861
2215
1829
1782
1838
...

result:

ok 4974 numbers

Test #38:

score: 0
Accepted
time: 12ms
memory: 182812kb

input:

5 4 1043134129
1 5 977642441
3 5 5090661
2 3 494599720
1 4 228151885
10
355176646
283620748
605736709
793837815
794803633
765091357
626890899
696011679
299013899
936453221

output:

10
10
10
10
10
10
10
10
10
10

result:

ok 10 numbers

Test #39:

score: 0
Accepted
time: 16ms
memory: 183776kb

input:

5 3 505611833
3 5 355189186
4 5 476920544
1 4 790069228
7
1049356499
845887979
133284766
62240514
677690440
918849227
108480136

output:

1
1
3
1
1
1
3

result:

ok 7 numbers

Test #40:

score: 0
Accepted
time: 19ms
memory: 183396kb

input:

7 9 521144263
2 3 875722201
1 4 484548684
6 7 850552655
5 7 833135649
3 5 567904308
2 7 220731296
2 6 253254105
3 7 530811591
2 3 689987863
10
151626227
200355065
809653136
645506652
211930525
691572228
936105977
173632884
303972688
59214444

output:

7
7
10
10
7
10
10
7
3
6

result:

ok 10 numbers

Test #41:

score: 0
Accepted
time: 12ms
memory: 184000kb

input:

7 8 359226584
2 6 737021945
5 6 610737480
5 6 917299569
1 2 240194284
3 7 181725565
1 3 448895611
1 7 442536198
2 7 727475653
8
375070078
693377796
982854221
394893886
333381744
22165260
740650832
983745737

output:

3
6
6
3
3
2
6
6

result:

ok 8 numbers

Test #42:

score: 0
Accepted
time: 11ms
memory: 183436kb

input:

9 3 574707371
5 8 787402867
4 6 688975747
2 9 108106111
6
249403994
504537415
117259043
55891847
576294083
5379852

output:

2
1
1
1
2
1

result:

ok 6 numbers

Test #43:

score: 0
Accepted
time: 15ms
memory: 184016kb

input:

4 9 706090739
2 4 350968802
1 3 602355257
3 4 783521964
1 3 747945779
1 4 844409052
3 4 324785736
2 3 1021045353
2 4 943976064
1 4 878513870
8
732972801
445870779
1036828634
581592791
456533345
457040329
777855221
50005779

output:

6
6
6
6
6
6
6
6

result:

ok 8 numbers

Test #44:

score: 0
Accepted
time: 11ms
memory: 183020kb

input:

5 8 410637692
1 3 573445776
1 4 11648423
2 3 45701738
1 4 462267744
1 5 454649150
1 3 351512083
1 3 199032270
1 5 717327820
1
935268986

output:

1

result:

ok 1 number(s): "1"

Test #45:

score: 0
Accepted
time: 15ms
memory: 184244kb

input:

7 5 657392172
2 4 590592365
3 6 206454850
2 7 713367077
4 5 106932526
2 3 599448331
8
253146025
1064967391
1049941051
489893117
605675459
907301017
808784423
87579874

output:

3
6
6
2
10
6
6
10

result:

ok 8 numbers

Test #46:

score: 0
Accepted
time: 20ms
memory: 182760kb

input:

2 9 156302601
1 2 751183875
1 2 122003273
1 2 827927890
1 2 477476954
1 2 61973209
1 2 22801957
1 2 536452596
1 2 721199228
1 2 566421483
6
751790799
43961444
461275881
935112396
559332109
933822486

output:

1
1
1
1
1
1

result:

ok 6 numbers

Test #47:

score: 0
Accepted
time: 16ms
memory: 183324kb

input:

9 6 675274642
1 8 499075708
4 5 65342133
3 7 1062637163
1 3 885380254
1 9 853093922
1 9 195696071
10
685362859
180966004
952637798
48027661
204790489
807975486
977862149
13876137
130973072
245475427

output:

6
4
10
4
4
6
10
4
4
4

result:

ok 10 numbers