QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#873910#9682. nim 游戏team13770 93ms89752kbC++145.1kb2025-01-27 08:49:442025-01-27 08:49:48

Judging History

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

  • [2025-01-27 16:14:54]
  • hack成功,自动添加数据
  • (/hack/1492)
  • [2025-01-27 09:21:28]
  • hack成功,自动添加数据
  • (/hack/1491)
  • [2025-01-27 08:49:48]
  • 评测
  • 测评结果:0
  • 用时:93ms
  • 内存:89752kb
  • [2025-01-27 08:49:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace file_read{
	char ib[1<<24],*ip1=ib,*ip2=ib;
	inline char gc(){
		return ((ip1==ip2)&&(ip2=(ip1=ib)+fread(ib,1,1<<24,stdin)),ip1==ip2?EOF:*ip1++);
	}
	inline int read(){
		int x=0;char c=gc();
		while(c<'0'||c>'9')c=gc();
		while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^'0'),c=gc();
		return x;
	}
	inline long long readl(){
		long long x=0;char c=gc();
		while(c<'0'||c>'9')c=gc();
		while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^'0'),c=gc();
		return x;
	}
}
using namespace file_read;
long long a[100005];
int n,m;
long long ann;
namespace yuchu{
	long long b[100005],c[100005];
	int z[100005];
	void solve(){
		for(int i=1;i<=n;++i)b[i]=a[i];
		long long ans=0;
		int ff=0;
		for(int t=59;t>=0;--t){
			int gs=0;
			for(int i=1;i<=n;++i)if(b[i]>>t&1)++gs;
			if(gs%2==0)continue;
			if(gs==n){
				ff=1;break;
			}
			long long T=(1ll<<(t+1))-1;
			long long mx=-1;int wz=0;
			for(int i=1;i<=n;++i){
				if((b[i]&T)>=(1ll<<t))continue;
				if(mx<(b[i]&T))mx=(b[i]&T),wz=i;
			}
			ans+=(1ll<<t)-mx;b[wz]+=(1ll<<t)-mx;
		}
		if(ff){
			ans=LLONG_MAX;
			for(int t=60;t>=1;--t){
				int gs=0;
				for(int i=1;i<=n;++i)if(a[i]>>t&1)++gs;
				if(gs%2)break;
				for(int i=1;i<=n;++i){
					c[i]=(a[i]&((1ll<<(t+1))-1));z[i]=i;
				}
				sort(z+1,z+n+1,[&](int x,int y){
					return c[x]<c[y];
				});
				int w=0;
				for(int i=1;i<=n;++i){
					if(c[z[i]]<(1ll<<t))w=i;
				}
				if(w>=2){
					for(int i=1;i<=n;++i)b[i]=a[i];
					int u=z[w-1],v=z[w];
					long long hh=(2ll<<t)-c[u]-c[v];
					b[u]+=(1ll<<t)-c[u];b[v]+=(1ll<<t)-c[v];
					int ff=0;
					for(int tt=t-1;tt>=0;--tt){
						int gs=0;
						for(int i=1;i<=n;++i)if(b[i]>>tt&1)++gs;
						if(gs%2==0)continue;
						if(gs==n){
							ff=1;break;
						}
						long long T=(1ll<<(tt+1))-1;
						long long mx=-1;int wz=0;
						for(int i=1;i<=n;++i){
							if((b[i]&T)>=(1ll<<tt))continue;
							if(mx<(b[i]&T))mx=(b[i]&T),wz=i;
						}
						hh+=(1ll<<tt)-mx;b[wz]+=(1ll<<tt)-mx;
					}
					if(!ff)ans=min(ans,hh);
				}
			}
		}
		ann=ans;printf("%lld\n",ans);
	}
}
namespace baoli{
	long long aj[100005];
	int p2[100005];
	int tt;vector<pair<int,long long>>vv[20005];
	long long aa[65][100005];
	int hh[65],pp[65][100005];
	int tj[100005],st[105],sl=0;
	bool dfs(int t,long long he){
		if(t<0){
			if(he>ann)return 0;
			--m;
			vector<pair<int,long long>>vc;
			for(int i=1;i<=sl;++i){
				int x=st[i];
				if(aj[x])vc.emplace_back(x,aj[x]);
			}
			sort(vc.begin(),vc.end());
			vv[++tt]=vc;
			return 1;
		}
		int gs=hh[t];
		for(int i=1;i<=sl;++i){
			int j=st[i];
			gs-=aa[t][j]>>t&1;
		}
		if(gs%2==0)return dfs(t-1,he);
		if(gs==n)return 0;
		int fl=0,cg=1;
		for(int i=n-gs;i>=1&&cg&&m;--i){
			int j=pp[t][i];
			if(tj[j])continue;
			if((aa[t][j]>>t&1))continue;
			long long sb=(1ll<<t)-aa[t][j];
			aj[j]+=sb;++tj[j];
			if(tj[j]==1)st[++sl]=j;
			int ff=1;
			if(dfs(t-1,he+sb))fl=1;
			else ff=0;
			if(tj[j]==1)--sl;
			--tj[j];aj[j]-=sb;
			if(!ff)return fl;
		}
		for(int i=1;i<=sl&&cg&&m;++i){
			int j=st[i];
			long long sb=(1ll<<t)-0;
			aj[j]+=sb;++tj[j];
			if(tj[j]==1)st[++sl]=j;
			int ff=1;
			if(dfs(t-1,he+sb))fl=1;
			else ff=0;
			if(tj[j]==1)--sl;
			--tj[j];aj[j]-=sb;
			if(!ff)return fl;
		}
		return fl;
	}
	void solve(){
		for(int i=1;i<=n;++i)p2[i]=i;
		sort(p2+1,p2+n+1,[&](int x,int y){
			return a[x]<a[y];
		});
		for(int t=60;t>=0;--t){
			hh[t]=0;
			int w=0;
			for(int i=1;i<=n;++i){
				aa[t][i]=a[i]&((1ll<<(t+1))-1);
				pp[t][i]=p2[i];hh[t]+=(aa[t][i]>>t&1);
			}
			for(int i=1;i<=n;++i){
				if(aa[t][p2[i]]<(1ll<<t))w=i;
			}
			inplace_merge(p2+1,p2+w+1,p2+n+1,[&](int x,int y){
				return (a[x]&((1ll<<t)-1))<(a[y]&((1ll<<t)-1));
			});
		}
		for(int i=1;i<=n;++i)aj[i]=0;
		tt=0;dfs(59,0);
	}
	void solve2(){
		for(int t=60;t>=1;--t){
			int gs=0;
			for(int j=1;j<=n;++j)gs+=(a[j]>>t&1);
			if(gs%2)break;
			int w=0;
			for(int j=n;j>=1;--j){
				if(aa[t][pp[t][j]]>=(1ll<<t))continue;
				w=j;break;
			}
			for(int j=w;j>=2;--j){
				int ff=0;
				for(int k=j-1;k>=1;--k){
					int x=pp[t][j],y=pp[t][k];
					st[++sl]=x;st[++sl]=y;
					++tj[x];++tj[y];
					aj[x]+=(1ll<<t)-aa[t][x];
					aj[y]+=(1ll<<t)-aa[t][y];
					if(!dfs(t-1,(2ll<<t)-aa[t][x]-aa[t][y])){
						--tj[x];--tj[y];--sl;--sl;
						aj[x]-=(1ll<<t)-aa[t][x];
						aj[y]-=(1ll<<t)-aa[t][y];
						break;
					}
					--tj[x];--tj[y];--sl;--sl;++ff;
					aj[x]-=(1ll<<t)-aa[t][x];
					aj[y]-=(1ll<<t)-aa[t][y];
				}
				if(!ff)break;
			}
		}
	}
	void output(){
		printf("%d\n",tt);
tt=0;
		for(int i=1;i<=tt;++i){
			vector<pair<int,long long>>vc=vv[i];
			sort(vc.begin(),vc.end());
			int z=vc.size();
			printf("%d\n",z);
			for(int j=0;j<z;++j)printf("%d ",vc[j].first);
			printf("\n");
			for(int j=0;j<z;++j)printf("%lld ",vc[j].second);
			printf("\n");
		}
	}
}
int main(){
	int c=read(),T=read();
	assert(c>=0);
	while(T--){
		n=read(),m=read();
		for(int i=1;i<=n;++i)a[i]=readl();
		yuchu::solve();
		baoli::solve();
		if(n%2)baoli::solve2();
		baoli::output();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 19ms
memory: 83668kb

input:

1 10000
2 1
787709928 658090405
2 1
508859442 320865978
2 1
901516660 1071318821
2 1
924326675 330656846
2 1
556507192 599101864
2 1
518528812 842021415
2 1
153781736 213270767
2 1
161460204 140517709
2 1
344895823 339053034
2 1
76824343 446590781
2 1
943442122 128864577
2 1
186128196 166832232
2 1
...

output:

129619523
1
187993464
1
169802161
1
593669829
1
42594672
1
323492603
1
59489031
1
20942495
1
5842789
1
369766438
1
814577545
1
19295964
1
441833213
1
682938449
1
138747082
1
450474039
1
148427150
1
512703429
1
720991430
1
248861028
1
414955183
1
198268104
1
392278219
1
537759970
1
280269185
1
185606...

result:

wrong answer Integer 187993464 violates the range [0, 2]

Pretest #2:

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

input:

2 5
5 2000
0 1 15 5 8
5 2000
0 13 11 14 7
5 2000
0 1 1 2 3
5 2000
0 7 4 4 9
5 2000
0 13 10 12 8

output:

1
2
1
1
1
2
2
4
1
1

result:

wrong answer invalid solution xor sum does not equal to 0 at test case 1

Pretest #3:

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

input:

3 5
5 2000
0 12 14 13 4
5 2000
0 14 5 5 11
5 2000
0 12 3 0 1
5 2000
0 8 5 9 11
5 2000
0 8 7 1 2

output:

9
3
3
10
8
2
5
7
2
1

result:

wrong answer Integer 10 violates the range [1, 5]

Pretest #4:

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

input:

4 5
5 2000
0 0 3 13 5
5 2000
0 9 10 14 3
5 2000
0 4 7 10 3
5 2000
0 9 14 5 0
5 2000
0 6 4 7 12

output:

5
5
8
2
4
4
2
10
7
8

result:

wrong answer Integer 8 violates the range [0, 5]

Pretest #5:

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

input:

5 5
6 2000
0 924 738 482 642 735
6 2000
0 506 297 82 577 913
6 2000
0 520 847 369 136 119
6 2000
0 690 849 528 740 840
6 2000
0 121 51 176 500 435

output:

189
420
175
3
41
8
553
7
69
18

result:

wrong answer Integer 175 violates the range [0, 6]

Pretest #6:

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

input:

6 5
6 2000
0 611 108 95 972 21
6 2000
0 477 6 212 751 342
6 2000
0 131 78 345 512 551
6 2000
0 606 560 666 251 1020
6 2000
0 837 1013 823 371 987

output:

183
54
172
45
139
25
13
3
273
3

result:

wrong answer Integer 172 violates the range [0, 6]

Pretest #7:

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

input:

7 5
6 2000
0 843 555 227 498 625
6 2000
0 365 658 849 181 373
6 2000
0 784 493 983 343 427
6 2000
0 628 848 762 675 423
6 2000
0 714 409 429 732 164

output:

58
122
104
5
298
3
44
10
130
1

result:

wrong answer Integer 104 violates the range [0, 6]

Pretest #8:

score: 0
Wrong Answer
time: 27ms
memory: 83492kb

input:

8 272
100000 100
268435456 16 2 16 256 2 131072 1 536870912 16 134217728 4096 2048 8 512 8388608 33554432 128 1 134217728 256 2 16777216 256 4194304 1048576 536870912 262144 16 67108864 536870912 268435456 1024 2097152 2 128 512 512 512 4096 8388608 524288 2048 268435456 16 16384 512 4096 8192 16 65...

output:

200828637
100
254
1
197087
27
227
81
51
4
63366
27
526
3
1702284
9
2108
9
61364
100
4178404
4
0
1
51196
1
12785
24
1254
100
2089857
100
167770143
1
9404424
72
120
3
61792
100
1
5
2
2
197124
3
934
1
113740928
27
16
4
27
45
8306
34
130935
100
26
100
31744
1
129859
9
31014
9
216
100
60
1
61054
9
194025...

result:

wrong answer Integer 197087 violates the range [1, 100000]

Pretest #9:

score: 0
Wrong Answer
time: 25ms
memory: 83808kb

input:

9 264
100000 100
64 32 4 67108864 4194304 262144 2048 1 8192 536870912 268435456 16 33554432 128 1048576 32768 2097152 536870912 2 1 8 64 1048576 4096 16777216 8192 2 16384 2048 2097152 16384 32 131072 2097152 2048 131072 134217728 134217728 4096 4096 32768 1048576 1024 268435456 2097152 16384 33554...

output:

341268837
100
2
11
7861
100
67096641
100
3
3
8376096
100
139263
100
977287
100
1846
9
6221564
9
438
9
11842
100
32509719
100
16387
1
31
9
28666
81
7460980
100
16288
2
61
100
274
8
1
4
417793
8
16376
81
12
66
2498
1
493182
100
18060
1
524274
48
61391
1
67101284
100
4
1
96
6
7278
27
7574526
100
0
1
25...

result:

wrong answer used stones does not equal to outputed k at test case 1

Pretest #10:

score: 0
Wrong Answer
time: 26ms
memory: 84056kb

input:

10 260
100000 100
2097152 2048 16777216 32 65536 262144 16777216 16384 524288 8192 1 2 1 32768 134217728 131072 2097152 1024 64 8388608 131072 4194304 2 262144 2 512 65536 2 262144 1 1 512 33554432 262144 32 8388608 1 16777216 524288 4 128 512 134217728 1 67108864 536870912 512 65536 32768 8388608 1...

output:

156152625
100
6930418
100
1
2
0
1
516097
2
9
2
131051
100
6324216
1
36
76
65476635
100
7937
27
28668
3
32
4
1109624
1
31
9
457754
81
2883904
1
7
24
128
100
7930676
9
200884176
100
246980
34
15
100
14738
100
352
64
1154
1
6787276
27
984
9
2
10
6278
9
990626
100
4194300
1
0
1
0
1
33026303
1
9
8
29635
...

result:

wrong answer Integer 6930418 violates the range [0, 100000]

Pretest #11:

score: 0
Wrong Answer
time: 66ms
memory: 86616kb

input:

11 1926
100000 1
0 212593154 1052140456 972928282 462369044 673421356 1030921469 775492985 523349355 1069594143 190488188 492043456 733126324 341798699 724636365 947318175 262485282 931417678 663669259 740799776 535456704 684181464 19065576 53174255 514941440 670957241 988117825 629697943 45145107 1...

output:

166
1
3507
1
330
1
2702
1
29425584
1
4458735
1
1
1
29731
1
24567
1
27
1
3432702
1
12
1
44
1
11
1
344564
1
6
1
2
1
493596596
1
651
1
2
1
8393
1
638498
1
0
1
2206417
1
5
1
4160592
1
553
1
2
1
62416
1
42
1
0
1
20
1
7
1
38196547
1
2841590
1
1880294
1
3116
1
23633364
1
180680973
1
57667944
1
1103
1
101
1...

result:

wrong answer Integer 29425584 violates the range [1, 100000]

Pretest #12:

score: 0
Wrong Answer
time: 71ms
memory: 85908kb

input:

12 2322
100000 1
0 7039776 731926398 236886500 253555357 170069043 850149498 316268635 795618622 1065678481 633285758 1009207086 237836472 1017789866 399181873 324785167 527514687 676377746 338198269 270887526 278879561 639366360 646568377 35830334 462432910 876996649 282011992 376880056 871143466 6...

output:

34074
1
9706
1
159051
1
28903264
1
557071
1
15
1
8277
1
29
1
8372224
1
129698
1
90112151
1
580
1
71
1
95673
1
10762
1
389580536
1
2
1
16785248
1
409
1
8
1
71
1
1990
1
14754
1
3
1
832412
1
8
1
2
1
3329
1
7663404
1
3081
1
1139600
1
541
1
1845
1
6536
1
970717
1
96
1
89835133
1
209
1
330
1
803
1
3
1
281...

result:

wrong answer Integer 159051 violates the range [1, 100000]

Pretest #13:

score: 0
Wrong Answer
time: 74ms
memory: 85224kb

input:

13 2464
100000 1
0 427935372 551832889 844721265 648958227 58702839 98231989 67300751 1070455997 255697378 699971877 1056963469 632702252 896835770 545070997 374682484 333464439 140377201 550440744 704064530 917272389 331841130 755945696 883819791 896333287 197663164 1004357948 335423689 95692127 34...

output:

5015
1
40747082
1
47341
1
3011
1
1
1
47629
1
67
1
39004
1
8173
1
49149
1
19
1
9570763
1
20994620
1
3274
1
17
1
36028
1
2628414
1
6
1
46571
1
126601
1
4
1
219681682
1
43
1
81910098
1
1461
1
33521670
1
21499
1
7
1
822997
1
20116
1
114590
1
4014
1
197
1
1
1
1044168
1
3
1
230
1
16602
1
162669
1
55
1
321...

result:

wrong answer Integer 40747082 violates the range [0, 100000]

Pretest #14:

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

input:

14 23
1000 10
0 698723699 153465147 73111165 241423619 281436251 113788324 332818071 542687168 77217995 707859065 70032469 945739237 152178890 73308725 1024104741 39038522 68449065 817070146 484673194 548054722 17751150 1033084930 799709329 351409876 1014395268 477743523 926399631 141641436 10162229...

output:

2629849
10
2364
3
69
5
4095
1
21
5
43
1
455068166
5
1
1
101501
5
83374
5
14677535
3
126612
5
0
1
340
5
298651871
5
364194
5
139593
5
2542
5
394978
5
1990
5
2
5
1038359
5
33457944
5

result:

wrong answer Integer 2364 violates the range [0, 1000]

Pretest #15:

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

input:

15 20
1000 10
0 325140143 399467215 271742503 190711881 796467699 212013868 800948731 598735180 276851093 459249598 988722552 598611576 105484598 808958849 841464615 178027765 508254895 206994337 1072632121 1049525925 403545743 729066403 167006626 616418294 1054659905 183353134 221931747 696125686 6...

output:

132910
10
12811
5
1
3
442
5
45645
5
17
5
139578
5
677068
5
6
5
2509171
5
4786
5
12442
2
84
5
4
5
47
5
435
5
8853553
5
2839
5
6300
5
2
1

result:

wrong answer Integer 12811 violates the range [0, 1000]

Pretest #16:

score: 0
Wrong Answer
time: 2ms
memory: 81644kb

input:

16 13
1000 10
0 482035639 676392463 177349717 883879216 637330885 636356465 296234635 413153479 243419329 335379052 28971145 245253558 649873071 989738887 859470495 546547468 165357700 205836231 930726901 836955479 527409688 413040184 425801996 723492123 804913055 914899671 430466328 1001437510 3421...

output:

938103
10
5
1
199879
5
650
5
11461498
5
745
5
1009
5
52900
4
1519
1
14194
5
4
5
3258
5
6151136
4

result:

wrong answer Integer 199879 violates the range [1, 1000]

Pretest #17:

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

input:

17 25
1000 10
0 204462620 639500437 1036012729 739663091 537559905 884930259 908629202 87714371 214733383 426959949 412554835 286343676 997368563 336872508 137649097 499408853 98787579 526714350 509336631 438105017 488897961 521760143 786808538 496422268 1006079836 855395010 204030938 325348670 4189...

output:

1515532
10
7880
5
32175
5
2
5
1635975
5
47112
5
65535
1
7168495
1
1444
5
2
5
21417089
5
37379
2
211
5
161117673
5
4197926
5
0
1
1606435
5
1625
1
36
1
493193
5
24
1
133165432
1
47
4
4371852
5
56
5

result:

wrong answer Integer 7880 violates the range [0, 1000]

Pretest #18:

score: 0
Wrong Answer
time: 50ms
memory: 87444kb

input:

18 235
100000 1000
0 82292805 542862389 496765580 714793373 1018727959 380589532 235510694 439236106 450402753 644037967 69084284 398499559 833754127 162045571 1073497987 905929801 414312207 964010413 690834864 244433021 782011334 138519454 409419856 431781810 1035339746 480460956 415997860 10156623...

output:

34345
1000
55105
4
6876093
100
5736
100
845876
40
1120
3
7
1
6589
100
1
1
76
6
3373585
100
99596
14
7196
100
59
32
18003407
100
179965835
100
0
1
0
1
1203
40
4045
100
78
8
194
99
19490
100
2
2
2047
2
1491329
100
5554836
100
25051673
8
2785
22
27
21
767
2
26
100
29264511
9
17757425
100
656927
100
897...

result:

wrong answer Integer 6876093 violates the range [1, 100000]

Pretest #19:

score: 0
Wrong Answer
time: 48ms
memory: 85600kb

input:

19 236
100000 1000
0 109677213 768433554 834865731 720533892 838023709 491602375 513068054 1030589833 94664107 745436908 1037219078 228408014 547804495 508518110 773484880 380678427 782156458 113943184 307779979 912132791 587642137 735393238 657215861 44405388 83221805 174662600 163585186 300009673 ...

output:

3319
1000
4118455
96
916983
100
23593159
63
85887583
100
130711298
7
8990790
100
86
46
6014
100
1378
1
85
2
1
1
5006
40
2163704
81
3118
3
88546
100
4972
24
6
1
2933
15
14
12
807
28
44359722
1
238
100
5089859
32
1242
100
7
1
21108071
27
141
18
23621400
2
785711
100
2173
16
3
4
1
1
5
3
42
3
5
1
1
2
12...

result:

wrong answer Integer 4118455 violates the range [0, 100000]

Pretest #20:

score: 0
Wrong Answer
time: 42ms
memory: 86048kb

input:

20 210
100000 1000
0 550139852 961781343 290521815 952492729 457397512 357809864 204830121 1140484 170664856 470999550 1055212876 691814384 638327612 265853133 674623701 160349476 763151462 881390841 355393034 667147513 628883665 627392037 395945621 565511024 979892315 870090061 43124702 944114976 1...

output:

533
1000
397864
30
165
6
15
2
7581
100
10
100
3
100
38
2
536870911
1
10
2
24
12
25573180
76
10891
100
3933056
1
24
19
84
6
21953316
100
0
1
0
1
4127132
7
1
1
1694
1
2
1
1927
3
56529730
3
3295881
100
5413425
100
1310863
100
602
100
1755190
81
18088833
100
67576
9
31200
3
2
24
77136293
100
1
2
3530
81...

result:

wrong answer Integer 397864 violates the range [0, 100000]

Pretest #21:

score: 0
Wrong Answer
time: 46ms
memory: 84620kb

input:

21 246
100000 1000
0 897255135 331582452 692933508 605776464 745133272 287951719 636521474 674882787 145593015 355040634 666511339 967360297 920416500 1010174993 220923757 1062201185 392857314 952622455 432831665 591343815 983505947 314879003 323044 876019636 3896524 753501041 48852262 176877973 104...

output:

18210
1000
21
4
2
1
441
27
23351248
67
4857
81
278
27
13101447
8
64284
1
93529
27
5725399
81
12666521
100
2
8
897
100
1430876
100
2
1
1412
6
241015616
100
1047310
2
6154
76
486148
3
5968
100
330
18
9775452
100
5
4
2
1
284945
100
10615848
4
1
2
1
1
99871546
1
12566
100
277
3
1395807
100
381
3
1
2
157...

result:

wrong answer Integer 23351248 violates the range [1, 100000]

Pretest #22:

score: 0
Wrong Answer
time: 44ms
memory: 85752kb

input:

22 237
99999 1000
0 19429538 32580338 239047420 111765496 237262980 10571876 197851450 233191405 192728811 23616992 2112605 201810362 35237428 102317792 1287284 107825938 219438710 182319519 243718852 90090242 90138990 118813262 207877046 233448598 224872276 5939550 82514558 103000114 13729014 79388...

output:

3840
1000
31351309
1
83901
9
159427233
100
4438571
2
38632
2
2453615
6
10
4
41
1
154113
2
2
100
2813
27
19511
1
375798
75
19627203
100
134217729
100
395824
2
394867
100
134313298
10
1
3
180368
27
298
3
430
27
35614
44
2549
100
251
2
9869461
100
3
3
8783688
30
79611
4
7903496
100
12408
1
867
7
257
10...

result:

wrong answer Integer 31351309 violates the range [0, 99999]

Pretest #23:

score: 0
Wrong Answer
time: 50ms
memory: 86672kb

input:

23 229
99999 1000
0 251252946 107619243 220631496 246783065 243267863 37598061 174732100 119356777 38068361 57156544 232667237 83660542 90081294 219829370 268237117 43024835 122172878 186256566 48858424 81564486 177620789 177890699 37297432 39654072 59706273 144598610 213246934 239565341 192674874 1...

output:

3129
1000
56
2
16722
16
13749
100
9
3
1177216
1
71158
1
70
1
303
4
150
96
210
27
314
18
2555392
2
1228051562
100
9007715
100
9525301
4
101669951
31
1
1
437
100
117058
81
31
3
1191
4
2299
8
39200
1
96
17
75327
100
266575866
27
7
3
0
1
9381028
100
8768699
100
610069
1
105752
9
220
1
71999207
100
25
4
...

result:

wrong answer Integer 1177216 violates the range [1, 99999]

Pretest #24:

score: 0
Wrong Answer
time: 89ms
memory: 87184kb

input:

24 295
99999 2000
0 144446187652890493 178777776597373669 235188002077979946 277503908732511739 47638688657611750 68964406333979880 151013710872842158 146243386861595119 99485082905765142 200318010185323152 282591375727049216 123011484444631758 286520503049914226 232871465119451744 18280893731725023...

output:

5526392210479
2000
9460024634
100
17151
2
4127586088690318
100
2079026164092
1
7429030
5
1370361970464
4
6747524909
100
82201620136
100
28014504
100
2228854339
100
2766709
100
34803624791
100
1033895
12
324606
4
1237693873983551
100
3647
1
1314367526540
100
47052691
100
10681785188352
6
26
6
3427459...

result:

wrong output format Expected int32, but "9460024634" found

Pretest #25:

score: 0
Wrong Answer
time: 93ms
memory: 87704kb

input:

25 302
99999 2000
0 158060258327551 71283336971520116 219425730293845004 160993545682455627 118267401240028100 71239693681579669 269286666497227789 93391159342185951 23853690640806525 151733498955852704 124666395764102330 67021920580696748 119814027172684125 70463976282802752 2939723111608543 127044...

output:

4114663026142
2000
2335329
100
819079542
100
150
51
618538149375
2
611171
12
198318974311
32
418279806478
100
45084672344682
100
1486642
100
10994853075510070
100
547493975737845
100
491
81
538063719145955
100
613268
100
183035449490106
100
38514218149486630
40
996432412608
1
51117025699
100
5167409...

result:

wrong answer Integer 2335329 violates the range [0, 99999]


Final Tests

Test #1:

score: 0
Wrong Answer
time: 19ms
memory: 81628kb

input:

1 10000
2 1
324097321 555675086
2 1
304655177 991244276
2 1
9980291 383616352
2 1
1071036550 795625380
2 1
682098056 68370721
2 1
969101726 685975156
2 1
973896269 354857775
2 1
196188000 606494155
2 1
754416123 467588829
2 1
495704303 558090120
2 1
618002000 491488050
2 1
741575237 9937018
2 1
1002...

output:

231577765
1
686589099
1
373636061
1
275411170
1
613727335
1
283126570
1
619038494
1
410306155
1
286827294
1
62385817
1
126513950
1
731638219
1
130065995
1
295114692
1
301034148
1
338094653
1
290055064
1
616102407
1
683296497
1
58868131
1
408003947
1
892535230
1
212031631
1
386722635
1
655774471
1
55...

result:

wrong answer Integer 686589099 violates the range [0, 2]

Test #2:

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

input:

2 5
5 2000
0 13 3 4 10
5 2000
0 3 9 1 11
5 2000
0 13 7 3 5
5 2000
0 1 13 9 2
5 2000
0 8 14 7 13

output:

0
1
0
1
2
2
3
2
2
1

result:

wrong answer used stones exceed outputed k at test case 2

Test #3:

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

input:

3 5
5 2000
0 4 14 5 7
5 2000
0 2 15 0 12
5 2000
0 1 14 0 5
5 2000
0 13 4 12 3
5 2000
0 10 10 1 11

output:

6
2
1
4
8
8
2
4
10
13

result:

wrong answer used stones exceed outputed k at test case 1

Test #4:

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

input:

4 5
5 2000
0 6 15 10 1
5 2000
0 15 0 13 10
5 2000
0 5 7 5 1
5 2000
0 13 3 2 15
5 2000
0 2 4 7 0

output:

2
5
8
2
4
2
1
1
1
4

result:

wrong answer Integer 8 violates the range [0, 5]

Test #5:

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

input:

5 5
6 2000
0 45 517 811 107 132
6 2000
0 382 576 805 419 579
6 2000
0 379 809 441 331 67
6 2000
0 565 776 959 852 383
6 2000
0 613 383 829 47 441

output:

146
20
179
2000
267
10
27
30
197
18

result:

wrong answer Integer 179 violates the range [0, 6]

Test #6:

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

input:

6 5
6 2000
0 75 173 555 637 905
6 2000
0 934 118 906 367 728
6 2000
0 244 321 598 625 469
6 2000
0 573 489 24 480 459
6 2000
0 424 356 750 623 871

output:

557
483
195
5
69
29
33
16
204
45

result:

wrong answer Integer 195 violates the range [0, 6]

Test #7:

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

input:

7 5
6 2000
0 886 972 226 813 407
6 2000
0 219 190 742 101 572
6 2000
0 590 423 516 1017 46
6 2000
0 388 807 207 205 647
6 2000
0 408 180 238 300 694

output:

176
25
36
3
466
2000
24
60
156
3

result:

wrong answer Integer 36 violates the range [0, 6]

Test #8:

score: 0
Wrong Answer
time: 26ms
memory: 83840kb

input:

8 257
100000 100
32768 65536 262144 32768 8388608 1048576 4 67108864 16384 32768 262144 8192 512 134217728 65536 4194304 262144 67108864 1024 262144 64 32 65536 2097152 268435456 1 2048 4194304 16777216 8 16384 2 2048 16777216 268435456 262144 1048576 8388608 16 268435456 2 128 4194304 262144 32768 ...

output:

303389274
100
1
4
188156
100
5
100
7388192
100
1044482
2
483
72
37979676
9
2897896
1
12592895
100
96
6
124
9
10447
100
4
32
6321
1
35
9
12582912
6
112
46
1163266
10
0
1
4730
6
276
22
80
1
66558
1
1957856
27
9310311
100
2893824
100
14
9
332222
3
3334016
3
3731840
3
1002
4
40994
1
58
66
6291456
6
1187...

result:

wrong answer used stones does not equal to outputed k at test case 1

Test #9:

score: 0
Wrong Answer
time: 27ms
memory: 84188kb

input:

9 266
100000 100
134217728 524288 8388608 4 8 8388608 33554432 4 536870912 4 16 8 33554432 33554432 256 65536 8 16 64 8 256 2048 268435456 256 8192 2 1024 65536 32 2048 134217728 8 1048576 8 16777216 33554432 1024 33554432 131072 16 2 33554432 8192 512 4194304 2048 268435456 256 536870912 16777216 1...

output:

269988539
100
128
100
2111
27
24648843
9
38738
100
771
1
522240
1
75467712
81
0
1
252
3
54475779
3
624
9
4812
3
534832868
100
774
1
5676058
100
100337
4
1026
1
328145
1
276328320
81
18973684
100
171452
3
520232944
100
1354336
100
2017
100
65416
90
0
1
1040527
3
33244
100
13
2
2
12
2064
8
8
100
89573...

result:

wrong answer Integer 24648843 violates the range [1, 100000]

Test #10:

score: 0
Wrong Answer
time: 29ms
memory: 87084kb

input:

10 269
100000 100
1048576 2 64 67108864 1024 67108864 268435456 32768 8388608 32 256 2 268435456 262144 524288 262144 2 524288 64 8192 262144 536870912 2097152 64 1024 2 1048576 128 2 8388608 512 32768 1 8388608 4 2 268435456 128 67108864 65536 2 8388608 2048 16 2048 4096 32768 1048576 32768 32 8388...

output:

471323918
100
522240
1
408220
27
15334
9
0
1
130666
3
28795
24
0
1
5046776
81
137216
100
17
6
10491514
10
106627
3
0
1
398
1
30
3
96585148
81
19
100
50405259
1
7208
1
112091185
24
2801
100
1041610
100
3005
100
66520960
3
32
1
5636927
1
2494360
9
14911
50
12288
3
11648
84
242
45
1536
6
63740
1
20
100...

result:

wrong answer Integer 522240 violates the range [0, 100000]

Test #11:

score: 0
Wrong Answer
time: 69ms
memory: 84120kb

input:

11 2323
100000 1
0 3170633 888529329 347839787 101667249 273239696 1028446182 411994109 710973319 298677951 299452068 519308796 361451040 488605068 74238166 997794448 478367019 532094220 747266199 217905213 682359917 774814810 234838947 456387659 38459020 434013070 633290806 173828476 94076883 56828...

output:

11962
1
1607036
1
106
1
3
1
126
1
727
1
64001
1
147
1
18
1
2820
1
6234491
1
163
1
316
1
1
1
6831
1
2
1
58512441
1
1095
1
190
1
14
1
14
1
25337127
1
3135892
1
9443
1
7
1
174
1
1
1
175
1
23492762
1
24504133
1
8
1
1
1
503446969
1
1
1
4
1
16777215
1
1673
1
15021249
1
394
1
866019
1
21182202
1
2701101
1
...

result:

wrong answer Integer 1607036 violates the range [0, 100000]

Test #12:

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

input:

12 2205
100000 1
0 684191025 220215685 982495864 602362406 687396179 439432236 81065680 398068897 269754402 306183653 309939439 664994998 1011962742 338161922 629593565 926305057 1026259775 711874360 69406110 426672919 208267066 551253027 9384823 26156203 778817402 654214308 527029151 1065024353 287...

output:

22539
1
5296170
1
2997548
1
10
1
73171
1
63846191
1
160
1
54472
1
80
1
30
1
8647672
1
48079473
1
534
1
388781939
1
33000512
1
27487079
1
2
1
535
1
18402845
1
500239140
1
20596370
1
538
1
70
1
1315
1
1308627
1
1172423
1
1296
1
10
1
4
1
83
1
0
1
597875
1
31
1
138
1
0
1
16
1
217
1
174066623
1
131999576...

result:

wrong answer Integer 5296170 violates the range [0, 100000]

Test #13:

score: 0
Wrong Answer
time: 72ms
memory: 85908kb

input:

13 2166
100000 1
0 58930516 543560994 783997157 728082180 789115629 549794748 81818067 214839912 203394814 711969322 908524000 570262778 992867922 359455295 88035653 412186516 937931728 331800409 545354553 535440658 894562512 657466952 555070606 469471475 1055263866 874958292 76960239 478302168 6800...

output:

8241
1
2846999
1
1605
1
21150
1
13
1
0
1
1667525
1
89607968
1
146855
1
30
1
232032
1
3116
1
2
1
43907922
1
6789
1
262673
1
1
1
6250528
1
593516
1
196
1
4
1
272629760
1
9338564
1
15019723
1
131806
1
3019
1
110370613
1
7
1
368886820
1
12
1
5
1
117
1
1
1
110
1
5187
1
16737
1
44904
1
1124
1
25
1
18
1
17...

result:

wrong answer Integer 2846999 violates the range [0, 100000]

Test #14:

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

input:

14 23
1000 10
0 357293452 452461848 986047039 546588280 762710079 767831017 39741545 416114273 515599366 1018969624 603342125 928112286 1053016142 240953466 533088067 1028134429 504727014 371307863 834428873 968387878 478550336 1047217797 1046651542 777749850 866989319 92995163 251915198 363285573 1...

output:

264227
10
5
1
7
5
4
2
91693223
5
2097370
5
31
5
49
1
15
5
307991771
5
140516
5
6
5
4103
3
179
5
1
2
13
5
468910091
3
468961
5
5
5
510
1
50097157
5
4346
5
32699
5

result:

wrong answer used stones exceed outputed k at test case 1

Test #15:

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

input:

15 23
1000 10
0 978686021 287986921 276311856 889616598 739968417 1060147652 463275477 172393699 591333230 983197307 235514434 330494755 449056272 882229818 781111474 275587745 980041928 334198691 305313012 415758352 947298893 950211162 909723054 961622596 917454340 161928901 404346316 369133631 103...

output:

709905
10
1148
5
199214
5
920
5
3412
5
51
5
0
1
12155683
5
524287
1
27
5
7669
5
2
3
1163
5
1399949
5
26291797
5
669663
5
18
2
121
5
492112602
5
3990400
1
2
2
65535
1
7178
5

result:

wrong answer Integer 1148 violates the range [0, 1000]

Test #16:

score: 0
Wrong Answer
time: 2ms
memory: 83664kb

input:

16 15
1000 10
0 631723071 149784582 965844254 515554472 887253148 467825521 981769969 1054193550 627909969 590277818 159342752 658063143 667914173 169490051 25536270 337269419 1056885019 980490575 750858271 553446484 347553447 376197986 1053224035 473470890 123586 97769047 761755924 510998818 256094...

output:

737485
10
264867077
5
65535
1
2097160
1
34
5
11648
5
144
1
1
2
13
5
666046
5
4
1
8
5
108104785
5
24
1
82
5

result:

wrong answer Integer 264867077 violates the range [0, 1000]

Test #17:

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

input:

17 25
1000 10
0 751950140 901599329 987895071 306253500 278530668 539473653 911723672 948474628 722632384 369217860 428703545 999113214 567923990 53499297 1013528916 263060554 669297221 349021033 832596533 893306880 892438572 345611286 331257977 488113061 578929864 881846255 320356815 76057168 70469...

output:

1119212
10
65316
5
1073741823
1
3
3
3610519
5
525
4
3
4
995
2
6
5
507
5
1
1
94
1
14709283
5
1307943
5
209426
5
197310664
5
3433909
5
221226
5
33541088
1
1
2
5
1
91
5
8
1
270150
5
24270
5

result:

wrong answer Integer 65316 violates the range [0, 1000]

Test #18:

score: 0
Wrong Answer
time: 45ms
memory: 87060kb

input:

18 195
100000 1000
0 828483622 617711013 242092397 1034026464 456205583 731635466 382894773 533786631 582730039 74863848 661821965 368857719 541353387 662605236 580923280 798012506 54823622 333416217 39292129 995195996 477140985 1014499425 362164396 970752859 879997855 96768859 1005365898 576674982 ...

output:

23456
1000
190129
100
4762892
81
127
1
3
2
652019
100
225944
27
45
3
13555
9
399951772
100
140030
100
2
7
12251168
27
3
18
209969103
1
247
4
879
1
2969
12
16776833
2
2
3
544
100
159680962
18
3
1
1
3
946
35
62914
2
2085
16
126211826
100
2654
100
3
3
59826
100
13597109
100
0
1
144039661
3
151
27
16306...

result:

wrong answer Integer 190129 violates the range [0, 100000]

Test #19:

score: 0
Wrong Answer
time: 40ms
memory: 84068kb

input:

19 228
100000 1000
0 230727359 951312015 741711018 367230626 775024687 130794976 435788836 781961691 736694220 427610697 1016199868 798240399 340962994 1006804448 708169239 976753368 364431996 495851435 246658001 190094424 1054346726 639713727 218794912 229693460 313349630 85091951 418997497 2734590...

output:

5906
1000
18135
100
1201
1
407255
2
5
18
14972
3
22
100
8325023
4
3303
25
31696
100
29
12
19489
100
401018475
100
7656
81
6276610
100
205182348
100
2
3
29379594
15
11
25
7265
6
6
10
38407
100
2
5
18602088
24
22
6
8397652
100
9
2
148660303
100
203
1
13220358
100
38532
100
212
9
2650
47
5
4
3845945
10...

result:

wrong answer Integer 407255 violates the range [1, 100000]

Test #20:

score: 0
Wrong Answer
time: 48ms
memory: 84368kb

input:

20 221
100000 1000
0 716795222 632538294 1008333912 248043863 1023411987 11954597 917179098 100756831 19780613 336926235 768679016 371044675 360783184 402042708 1056697208 567354265 284551620 146863144 1008241012 536649321 680142584 506474136 80860918 973856876 30288601 668537691 877380398 131785980...

output:

13893
1000
71742222
100
19
8
32784
1
1000
5
1857268
19
109048
5
254598075
100
916362
2
3147950
14
104859934
1
10
1
1017
4
4963
100
3
1
142293
100
1525
15
1
1
26577
4
29
100
392
100
10450940
6
20761
21
61
100
1520
100
370584
100
285402
23
17
3
0
1
2565707
100
6086
100
33167
100
0
1
2158916
100
0
1
14...

result:

wrong answer Integer 71742222 violates the range [0, 100000]

Test #21:

score: 0
Wrong Answer
time: 41ms
memory: 86800kb

input:

21 204
100000 1000
0 867143449 289720871 62880653 256495758 373546157 114942061 524281177 164218453 261500635 241690011 911469619 794136322 460604293 201667773 1001245336 873383805 136426866 731765422 1036091702 428463064 474020221 916532901 913755707 704796468 745115429 387268771 611877390 10158806...

output:

1241
1000
784
1
109
9
1
1
158667
72
169557
100
5
9
64202
2
2673701
100
0
1
10
1
1
4
36592
5
0
1
63
100
1
100
19354090
6
290
100
307499
18
18162817
100
113920
3
34
5
3058
100
14375
100
5980385
100
15
100
15
1
5
7
892269
100
27493
20
76137
1
94441144
100
8
37
5685
100
671056
100
26133518
100
32021
19
...

result:

wrong answer Integer 158667 violates the range [1, 100000]

Test #22:

score: 0
Wrong Answer
time: 51ms
memory: 84240kb

input:

22 259
99999 1000
0 184042404 114860590 81955939 149152356 141033215 259145072 144981065 194732174 87943638 3239431 196977178 27923106 209711053 259763893 143914852 152580789 5161376 220134523 49139129 179593854 115442954 268238166 42599190 6509126 76156465 153820967 111093283 89981466 186373935 684...

output:

553
1000
42746320
100
6761
100
3480
8
1298539109
12
4350097
100
14
12
5
6
18
2
232438
5
106
8
13
4
4395492
8
92311
81
1953
2
302910399
2
151394971
100
490939
1
5239328
7
573397
10
604044810
12
1093
9
8064
1
41614585
100
554
24
477
1
578568
3
2590831
36
543
1
7784
27
5
100
553
9
526
1
4
1
19145
15
44...

result:

wrong answer Integer 42746320 violates the range [0, 99999]

Test #23:

score: 0
Wrong Answer
time: 56ms
memory: 86924kb

input:

23 229
99999 1000
0 67684423 27530736 262933500 210540490 87986446 142495215 8108489 162333902 7472566 74649932 22340176 96113149 105072940 96282592 479313 231805795 113210597 21907161 131354773 137785844 44861082 60046190 195538723 185926550 49537906 255986573 48373131 153611664 98228321 259354412 ...

output:

1406
1000
76226279
16
8710
100
1027
6
10
8
484142
1
2268
100
75825
36
1974761
2
3
1
6
1
3259813
88
9754794
100
1165
2
435
9
15872
1
1580866
9
153600
1
14
3
267
100
2
3
105
42
2
21
14
2
9
2
4638243
100
322037
2
2360
100
9644
100
1012175552
100
19037716
18
0
1
19
1
466
81
16518
100
5120
8
30476
3
3733...

result:

wrong answer Integer 76226279 violates the range [0, 99999]

Test #24:

score: 0
Wrong Answer
time: 79ms
memory: 86456kb

input:

24 299
99999 2000
0 46856671573051356 144451722821279396 194202742420356088 42768202435393968 146930968341077918 121735975802283045 43381059403904591 9790356926653248 90585698509588415 182205406048046442 106698163084666387 83495547377102990 95530264027271484 151047337738852707 263069394355867183 215...

output:

3144886350134
2000
171390666309632
2
40813686188869
100
9
14
3827735658
100
298766967590
12
624193874495696
100
158581180356032222
100
17483
100
1219144
100
16005705485
2
7117548522
100
79092772551864
100
11113406150121450
100
308536016766
1
653878648732044
48
9308526
33
19912642
100
14359442890301
...

result:

wrong output format Expected int32, but "171390666309632" found

Test #25:

score: 0
Wrong Answer
time: 89ms
memory: 89752kb

input:

25 308
99999 2000
0 62481075687254565 108220925926439751 147822046782831506 143330595029626008 266264147751224285 261103833765129444 47417861284547971 240063309104990334 57610062682346847 86133126920120030 166996559481841953 262167570538721871 37862622740033692 1564310050448344 238599881630673329 84...

output:

1899280322188
2000
618202410787
100
653774
1
31775
2
156807277242969906
100
279243237900
100
130250079
10
76545325130784
100
275
6
306921827
100
970328
2
3
1
32
1
9662108215241
6
2271482341449
100
285108420
4
15
27
6877812811336
100
10192418
100
15640300
100
244652
2
64871
7
64
1
788824884073230
100...

result:

wrong output format Expected int32, but "618202410787" found