QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#53947#3507. Broken Device 2not_so_organic100 ✓11ms4200kbC++203.8kb2022-10-06 13:33:202023-09-14 02:27:28

Judging History

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

  • [2023-09-14 02:27:28]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:11ms
  • 内存:4200kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-22 10:34:54]
  • 评测
  • 测评结果:100
  • 用时:28ms
  • 内存:3248kb
  • [2022-10-06 13:33:20]
  • 提交

Anna

#include "Anna.h"
#include <utility>
#include <vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
namespace {

ll dp[1005][2];
int n;
vector<int> solve(int x,int fl,ll nw)
{
	vector<int> ans;
	//printf("solve:x=%d,fl=%d,nw=%lld\n",x,fl,nw);
	if(x==1&&fl==1)
	{
		ans.push_back(1);
		return ans;
	}
	if(dp[x-2][fl]>=nw)
	{
		ans=solve(x-2,fl,nw);
		ans.push_back(fl);
		ans.push_back(fl);
		return ans;
	}
	nw-=dp[x-2][fl];
	ans=solve(x-3,fl^1,nw);
	ans.push_back(fl);
	ans.push_back(fl);
	ans.push_back(fl);
	return ans;
}
}

int Declare() {
	dp[1][1]=1;
	for(int i=1;;i++)
	{
		if(i>=3)
		{
			dp[i][0]=dp[i-2][0]+dp[i-3][1];
			dp[i][1]=dp[i-2][1]+dp[i-3][0];
		}
		ll sum=0;
		for(int j=1;j<=i;j++)
			sum+=(dp[j][0]+dp[j][1])*(i-j+1);
	//	printf("i=%d,dp=%lld,%lld,sum=%lld\n",i,dp[i][0],dp[i][1],sum);
		if(sum>5e17)
		{
			n=i;
			return n;
		}
	}
}

std::pair<std::vector<int>, std::vector<int> > Anna(long long A)
{
	ll nw=(A+1)/2;
	int fl=A%2;
//	printf("Anna\n");
	vector<int> ans1,ans2;
	for(int i=1;i<=n;i++)
	{
		if(nw<=dp[i][0]*(n-i+1))
		{
			int u=(nw-1)/dp[i][0];
			ans1=solve(i,0,(nw-1)%dp[i][0]+1);
			for(int i=1;i<=u;i++)
				ans1.push_back(i%2);
			break;
		}
		nw-=dp[i][0]*(n-i+1);
		if(nw<=dp[i][1]*(n-i+1))
		{
			int u=(nw-1)/dp[i][1];
			ans1=solve(i,1,(nw-1)%dp[i][1]+1);
			for(int i=1;i<=u;i++)
				ans1.push_back((i+1)%2);
			break;
		}
		nw-=dp[i][1]*(n-i+1);
	}
//	printf("Anna\n");
	int sz=ans1.size();
	for(int i=1;i<=sz;i++)
		ans2.push_back(i%2);
/*	printf("ans1=");
	for(int i=0;i<(int)ans1.size();i++)
		printf("%d ",ans1[i]);
	printf("\n");
	printf("ans2=");
	for(int i=0;i<(int)ans2.size();i++)
		printf("%d ",ans2[i]);
	printf("\n");*/
	if(fl)
	{
		for(int i=0;i<sz;i++)
			ans1[i]=1-ans1[i];
		for(int i=0;i<sz;i++)
			ans2[i]=1-ans2[i];
	}
	return make_pair(ans1,ans2);
}

Bruno

#include "Bruno.h"
#include <utility>
#include <vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
namespace {

ll dp[1005][2];
int n;
void build() {
	dp[1][1]=1;
	for(int i=1;;i++)
	{
		if(i>=3)
		{
			dp[i][0]=dp[i-2][0]+dp[i-3][1];
			dp[i][1]=dp[i-2][1]+dp[i-3][0];
		}
		ll sum=0;
		for(int j=1;j<=i;j++)
			sum+=(dp[j][0]+dp[j][1])*(i-j+1);
	//	printf("i=%d,dp=%lld,%lld,sum=%lld\n",i,dp[i][0],dp[i][1],sum);
		if(sum>5e17)
		{
			n=i;
			return;
		}
	}
}
ll solve(vector<int> ans)
{
	int len=ans.size()-1;
	if(len==1) return 1;
	int fl=ans[len];
	if(len==3||ans[len-3]==fl)
	{
		ans.pop_back();
		ans.pop_back();
		return solve(ans);
	}
	ans.pop_back();
	ans.pop_back();
	ans.pop_back();
	return solve(ans)+dp[len-2][fl];
}
}

long long Bruno(std::vector<int> u)
{
	if(!n) build();
	int sum=-1,las=1,sz=u.size(),fl=0;
	if(!u[0])
	{
		for(int i=0;i<sz;i++)
			u[i]=1-u[i];
		fl=1;
	}
	vector<int> ans;
	ans.push_back(0);
	ans.push_back(1);
	for(int i=0;i<sz;i++)
	{
		sum+=u[i]*2-1;
	//	printf("i=%d,u=%d,sum=%d\n",i,u[i],sum);
		if(sum==2)
		{
			if(las==1)
			{
				ans.push_back(1);
				ans.push_back(1);
				sum=0;
			}
			else
			{
				ans.push_back(1);
				ans.push_back(1);
				ans.push_back(1);
				sum=0;
			}
			las=1;
		}
		if(sum==-2)
		{
			if(las==0)
			{
				ans.push_back(0);
				ans.push_back(0);
				sum=0;
			}
			else
			{
				ans.push_back(0);
				ans.push_back(0);
				ans.push_back(0);
				sum=0;
			}
			las=0;
		}
	}
	int len=ans.size()-1;
	ll nw=0;
	for(int i=1;i<len;i++)
		nw+=(dp[i][0]+dp[i][1])*(n-i+1);
	if(ans[len]==1) nw+=dp[len][0]*(n-len+1);
/*	printf("nw=%lld,solve=%lld,ans=",nw,solve(ans));
	for(int i=1;i<=len;i++)
		printf("%d ",ans[i]);
	printf("\n");*/
	return (nw+solve(ans)+dp[len][ans[len]]*(sz/2-len))*2-fl;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 4188kb

input:

1000
2
00
2
11
4
0011
4
1100
6
010100
6
110011
8
00110011
8
11010100
10
0100110010
10
1010101011
12
001010110101
12
101010110010
14
00110101001100
14
10110011001011
16
0100101100110011
16
1011001101001010
18
010101001011010100
18
101100101101001101
20
01010100110100101011
20
10110011010100110010
22
...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

input:


output:

140

result:

ok m = 140

Test #2:

score: 5
Accepted
time: 5ms
memory: 4196kb

input:

1000
180
001000001011001101010100110101010100110010110010110101010011001101010010101101010010101100101010101011010101010101001101010011001010101010110100101010101101010011010010110010101101
180
1101110111001101001011010100110011010100110101001011010100110010110101010011001101001011010101001100110010...

output:

1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
...

input:


output:

140

result:

ok m = 140

Subtask #2:

score: 5
Accepted

Test #3:

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

input:

1000
94
0100111100010010010100101101110111111101010100011011000010000100010100101011001010101101010100
118
0111011000101101111111111101011011111111101111110100110101010101010011001101001101001101010101010011001101010010110010
200
1010110100011011110010100010001101110010000011111010010011011100101100...

output:

2392149
3237369
2749856
2195337
1287710
2355845
3335395
3368329
3788433
3809503
2138066
3919234
3445205
1969808
2611344
2738622
102224
3755713
692366
1999357
1791368
1080377
2887807
292605
3650162
2047893
2886267
1927376
3812776
1734518
521926
417160
3517895
3437895
1741109
2515055
2130145
1493727
1...

input:


output:

140

result:

ok m = 140

Test #4:

score: 5
Accepted
time: 4ms
memory: 3904kb

input:

1000
120
110100000011101111101101110000111011110110110110110010100100001000110101010011001011001010110010110100110101001100110010
262
1011010101101000110111000011101100010011110110100011110101101111010010101010110010101100110101010100101100101100110010110010101011001101010101010011001101001010110011...

output:

3247998
2952264
101276
3985524
3481871
1597107
3102982
3200769
3944600
2638234
857913
1577621
929409
1919652
544240
852963
1790135
212465
3013164
2949591
127124
1297806
1856199
3039926
2515945
2102087
1462642
132487
574908
500789
1691249
635288
2102814
2987943
1680123
135165
14678
3784008
3163536
26...

input:


output:

140

result:

ok m = 140

Test #5:

score: 5
Accepted
time: 8ms
memory: 3912kb

input:

1000
254
00111110111110111101011101110101100101010000110101111110100011001101001010110010101101001010101101010101001011010101001101010100110011001101010011001011001100101011001011001100110010101100110011010010110011001101010011001011001010101010110011001010110100
132
00001000110111010101110010010000...

output:

2928097
288621
493405
2654107
1392477
2720264
695372
3246724
3873799
1943259
36019
3099034
2080793
264593
1251607
796288
2422366
2512087
15926
1481435
79016
3777761
2022970
920671
347165
3723201
311611
2228046
354289
2867459
2249190
478736
3044429
840358
3511060
3254619
842641
3999896
2458483
147725...

input:


output:

140

result:

ok m = 140

Test #6:

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

input:

1000
238
0011101100010100010011101010010111101100001011111111111010110010110010110010110011010101001011010010101011001100101011001101010101001100101011001101010101001011010100110010110100110010110100110101010011010011001100110011001100110100110100
252
110110111101100101010101110101011011111011000100...

output:

3767405
1695402
1062411
520565
3753621
2849376
3544378
3642084
1041553
2246415
3636456
2175599
1208697
1285012
973829
1829274
348285
2682972
3232655
1600823
406856
2199316
353863
69430
3039540
3142014
168684
1207681
3945314
965971
358058
3182008
176715
1601189
2141110
32793
798136
3097583
3776345
37...

input:


output:

140

result:

ok m = 140

Test #7:

score: 5
Accepted
time: 4ms
memory: 3908kb

input:

1000
100
1011011111110010010010111011000101010110010000110110110111010111011101010101001101001101010010110100
70
1001010011111100000100111101010010010011010101110100000100100010010101
124
0100111010010101010001000011111101010111111010010000111011011011110010101101010010110100101011001101010010110101...

output:

2411978
1765946
3265867
2545974
1826937
805418
3154938
3052442
24781
1476109
3308102
2969474
1833779
494220
59723
3155918
503704
3941543
2213661
846943
3910588
1104614
3619613
1556790
3232609
2475271
2516715
3641605
3120720
2979060
1980061
527445
3930920
1088555
3220479
3373216
2150502
3028732
71176...

input:


output:

140

result:

ok m = 140

Test #8:

score: 5
Accepted
time: 2ms
memory: 3840kb

input:

1000
76
1111011100000000111011101101101110101110101101000001000101001101111100101010
76
0010000011110110111011000000100100010010010011111101101010110001000101001011
76
1111000100010101001001000011111011110111101011010100010010000101111100110100
76
0010001101110110111111010100000001010001000011101111...

output:

4000000
3999999
3999998
3999997
3999996
3999995
3999994
3999993
3999992
3999991
3999990
3999989
3999988
3999987
3999986
3999985
3999984
3999983
3999982
3999981
3999980
3999979
3999978
3999977
3999976
3999975
3999974
3999973
3999972
3999971
3999970
3999969
3999968
3999967
3999966
3999965
3999964
3999...

input:


output:

140

result:

ok m = 140

Test #9:

score: 5
Accepted
time: 3ms
memory: 3776kb

input:

1000
76
1110110111010000010100100011110111010111111100000010100101010110101111001100
76
1101110110010100101000010111010111010111011101101000010100010101101110110010
76
1101110110010101010000001101111110111011110001000010010010110111101011001100
76
1101011111010001001010000100111101111101110101110100...

output:

4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000000
4000...

input:


output:

140

result:

ok m = 140

Subtask #3:

score: 3
Accepted

Test #10:

score: 3
Accepted
time: 8ms
memory: 4136kb

input:

1000
172
0010010011010111111010111011111100001010001111001000001010010110110100010101010011010100110011010101001100101100101010110100101100110010110100110100110101010011010010110011
224
110000010010000101011100100100111010111011011011110001010111010000111100101011001011010100110100110100110101001011...

output:

7846775
8382012
6960772
2404116
8677412
678745
979722
6774319
3437411
7700246
3932261
582072
2662108
1913302
9666010
3371652
2312541
4159600
8783066
993904
5398654
7248427
8232055
3643242
5202338
290310
1551528
3983196
7816277
5663064
8661901
964937
8144699
6117845
8804933
9971775
5436597
3766214
79...

input:


output:

140

result:

ok m = 140

Test #11:

score: 3
Accepted
time: 4ms
memory: 3900kb

input:

1000
150
111010000100010100101000101111000010001101101010010011010111110110101101001101001101010101010100101010110100110100101011001011001010110101001100110011
172
1010001111000100110111101101010100010000110111000100010010000000101010101010110100101010110100110101010101001010101011001011001100110100...

output:

2579500
3476332
4512501
865937
5540101
5206780
8037675
3675478
8821453
7441051
7676364
338309
976749
946802
3291356
3888882
2478300
1886237
1406259
6251160
2208800
2104502
1931051
1049985
2329662
9349976
5608090
9767861
8144967
3417504
7418611
3118179
4298349
6201707
9025067
6059364
9663241
450971
5...

input:


output:

140

result:

ok m = 140

Test #12:

score: 3
Accepted
time: 8ms
memory: 3932kb

input:

1000
220
1111000010001011101101001000111011000100000011011111000101001101001011010100110101010011010010110011010010110010110100101101010101010101001100101101010011001101001100110010101010101100110100101010110101001100101010110010
114
000100111100000101010000110101110110101000010001101110111101011100...

output:

2145720
7247151
3955792
5119375
102397
6995413
5642360
3131787
5371462
6379650
2328491
8471151
1946249
7566503
6637905
3697742
5543077
408761
7967610
6892138
1101909
2691849
184908
8016601
4624752
9101543
9572339
1216864
3218036
2518886
7443559
6023379
1953149
1938765
837135
2363275
3523721
4435652
...

input:


output:

140

result:

ok m = 140

Test #13:

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

input:

1000
96
001110110100101001001101111011000011110101001000100011010101100001000010111011110100101011010101
236
10111100001001110111000011101011101010111011011111000010010010101000010010101100101100110010110100101011010100101101010101010100101011001010110011010100110101001010110011010101010011001010101...

output:

9239125
6470044
4672895
4176665
4788657
3211270
3879021
9473641
521084
253145
6033154
5127031
625904
9212465
65924
9956651
2252087
8260418
9895546
7429426
846905
5204965
7241285
9494999
840621
3490412
1263815
5507791
8148607
6275485
1999058
1528587
7924593
4980468
3054715
6609458
4350579
5735464
804...

input:


output:

140

result:

ok m = 140

Test #14:

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

input:

1000
228
101111011110101000101110110010000000001001010100110101001010101100110101010101001010110011001100101100110100101010101011001100101100101101001101010011001100101100110101001101001010101101001010101010110101001101001101010100101010
276
0010111011010101011100000010010100101110110010000011011011...

output:

245066
6788319
1673516
1668834
394553
2942265
555022
6915166
2504160
1167605
3060080
5061148
7819952
4994649
4012235
5538388
3227745
3332942
4170563
4170898
1363994
9468160
2991713
1733063
9809544
852809
5008917
2273965
3916627
9975559
9716708
7799492
6082722
4525699
6435787
7981909
1178233
462472
3...

input:


output:

140

result:

ok m = 140

Test #15:

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

input:

1000
152
10111101000010111100100001010011011100000100000010001110111010000100101101001011010011010100110011010010110100101101010101001101001101010100101010101100
152
00100011110010011110101001011101111010110111110100101000100010101010101101110111001101001100110101001100110100101100110011010011001101...

output:

10000000
9999999
9999998
9999997
9999996
9999995
9999994
9999993
9999992
9999991
9999990
9999989
9999988
9999987
9999986
9999985
9999984
9999983
9999982
9999981
9999980
9999979
9999978
9999977
9999976
9999975
9999974
9999973
9999972
9999971
9999970
9999969
9999968
9999967
9999966
9999965
9999964
999...

input:


output:

140

result:

ok m = 140

Test #16:

score: 3
Accepted
time: 5ms
memory: 3824kb

input:

1000
152
11101000110101110100001000110110110001001000100100000101001011010101111011010100000100110010110100110100110100110101001100110011010010101100110101010010
152
11011100010110110000100011110010000000100010001101011101101100010100010011001101010100101011001101001011010100101101001010110101001010...

output:

10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
100...

input:


output:

140

result:

ok m = 140

Test #17:

score: 3
Accepted
time: 2ms
memory: 3896kb

input:

1000
98
11101101010100001001101111111011110110111101000111000000110100101010110101010011010101001011001011
104
10111010101111010111110001010001001101110100000000100010010011101111110100101101010010101010110100110010
176
11101110111100001001000100000000100101010101111100110010110010101101001101001010...

output:

3153792
4161536
523264
2542806
2796202
2715035
127
1048575
2405805
4997816
854
4194288
3365266
2097120
4161528
5000490
2097088
4229086
9999049
2738419
4997529
9999460
195
2097151
4129023
4997159
9998647
8126431
4194303
262143
2796202
2796194
1665
5001324
5001890
32640
4161791
2467411
611027
636635
4...

input:


output:

140

result:

ok m = 140

Test #18:

score: 3
Accepted
time: 8ms
memory: 3976kb

input:

1000
194
00001110110100100100010101110110111110111011011111000100111011001100101011001100110011010100110101001101010101001011010100110101001100110101010101010100110100110100101101001100110100110010101100
210
11011000100000100000100101011010111010010100101010001111111100110101001100110100101100101011...

output:

2080767
2778778
8386560
263
5000855
5588341
9999126
5592407
5594453
254
262140
4996865
9997774
3678144
5592437
524352
1966080
326
6285999
4128895
1048544
2061203
32764
1032319
680
1693
1265501
8565439
2796202
16256
25
9850730
9998672
2788010
5313877
1387923
7713052
399
9998730
4128768
9999888
279620...

input:


output:

140

result:

ok m = 140

Test #19:

score: 3
Accepted
time: 5ms
memory: 3896kb

input:

1000
82
1111010010001101111110110000001010100011110110110010001000001101001010101100101011
272
0000001011001010101101010100101100110011010011001101010011010101001101001101010101001100110010110101001011001011010011001100101100110010110011010101001101010010110010110010110011010101001011001010101101010...

output:

1796388
1093
524885
1657
5592405
5592405
4998184
4178944
2796202
4186048
5625173
9998208
9997035
262143
9999343
7551730
5592401
5001314
9997285
1023
522
5001860
130560
3
2101184
1048576
4194431
9999335
1
3353805
2064895
2935661
4129279
4999239
4194296
1898
179
3564902
4997984
8322047
2279
2871
93685...

input:


output:

140

result:

ok m = 140

Subtask #4:

score: 12
Accepted

Test #20:

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

input:

1000
102
010101011011110000001110110000111010101101101111011111010000110110111011101101011011001101010100101100
186
0000110110111110111111001001010101010111001000101001111101110111000000010100110010101011010101001100110010110011001101010100101011010011001100101100110011010101001100101010101101001100...

output:

15956231
23535293
66108782
76299132
84142489
25718171
57561918
32167601
43128707
63301113
9513530
40626665
56101183
89657167
3515827
20572363
78089362
14278373
23319842
91902319
91000725
4434717
85582003
7705024
51561460
41307111
80160111
79814243
19629867
31981630
5816326
61400176
53220176
4104664
...

input:


output:

140

result:

ok m = 140

Test #21:

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

input:

1000
242
01000100001011110111101100100100010101001011110001000011101100010100001011011101111010001010001101001010101100110011001100101101001101001101001010110010101010101100110100110100101010101100101101001011001011010010101100101011010101010101010010
208
01110111111010010001010011101100100010001111...

output:

74786795
93573147
85600935
90665120
82896416
96616323
97955957
39336111
98463811
88462069
92026465
44224203
99956522
15122746
51675409
47004984
22237416
54252106
11959605
59061471
29657823
27401036
86636055
13228859
71794051
3143320
82164887
19741981
82284301
70613471
69931863
73167536
48280038
1346...

input:


output:

140

result:

ok m = 140

Test #22:

score: 12
Accepted
time: 4ms
memory: 3932kb

input:

1000
202
0100100011101010000100000101010110110100001101101001011110110010001010011011110011010100101101010101001010101011010100101101001101010011010011001010101011010011010100110010110011010101010011001010110100
142
111111101110110010000001010010100001010110110110110100000101010110110001001000110101...

output:

31525101
22182906
29170262
25825379
2068254
93493773
75739192
38626545
71425256
56335590
19693904
30250295
69640025
52097195
8719174
90761332
5776489
98599527
5153
19792597
32493647
58078516
5113056
50009050
99941217
12817120
24728804
82273526
64862353
44063931
42979108
38152512
60383371
33602192
53...

input:


output:

140

result:

ok m = 140

Test #23:

score: 12
Accepted
time: 7ms
memory: 4196kb

input:

1000
120
010000111011000010000101001111010100100101110001001110111111010110111100001010010001101100101100110010101101001101001011
244
0001101010101100100100000100100011101101000011101110110000101000010001010100100101101101101101111101010010101011010010110011001100101010101011010010110100101101010101...

output:

82375883
98207185
99007767
3149992
63037023
50029778
60358442
98234828
52042169
47711968
10796067
73904370
80286483
45778381
11060564
98121223
86070418
98508168
67753675
64433577
2135698
1746208
34283687
63616705
40286143
5001417
61578467
51153199
55871219
90367890
64496912
15805659
80143696
1933056...

input:


output:

140

result:

ok m = 140

Test #24:

score: 12
Accepted
time: 2ms
memory: 3884kb

input:

1000
176
11110000001000010011101111001001000000001011011110110001000101110100101100110100101101001010110100101011001100101010101101001011001010110010101010110010110100110010110101010010
254
00001000101011010101110101001001010101111011001000111101111101111111011101010010001010001110110111001100110011...

output:

13544396
57937115
6939462
4313715
31368081
42042541
27189738
83387020
26212662
80295786
59324332
38942968
56934885
2275789
41665360
25148670
52230998
43682769
9924503
71318763
56405382
1015412
92358146
82223209
40504249
76158997
95152
64200070
96841388
98832871
82244882
26110101
92134465
50632744
34...

input:


output:

140

result:

ok m = 140

Test #25:

score: 12
Accepted
time: 8ms
memory: 3784kb

input:

1000
258
111011110111011010001011101001010010100011101100010010101000110110111111001000010000100100010011010011010100101010110100101011010010101101001100110101001011010100101011001010101101010011001011001100101010101101001011010100101100101011001101010100101010110101
258
0001000010010000111101000011...

output:

100000000
99999999
99999998
99999997
99999996
99999995
99999994
99999993
99999992
99999991
99999990
99999989
99999988
99999987
99999986
99999985
99999984
99999983
99999982
99999981
99999980
99999979
99999978
99999977
99999976
99999975
99999974
99999973
99999972
99999971
99999970
99999969
99999968
99...

input:


output:

140

result:

ok m = 140

Test #26:

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

input:

1000
258
111011101110111100100011110101000100010110110100001000110111111101010010101001000001000000101011001101001100110100110100101101001010101010101010101010110101001011001011010101001010110101010100110101001100110010110100110011001011010100101011010101010011010011
258
1111011110111101001001011010...

output:

100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
100000000
...

input:


output:

140

result:

ok m = 140

Test #27:

score: 12
Accepted
time: 5ms
memory: 4160kb

input:

1000
108
110010000100101001000100111101011011110010001111111010000011011101101111011101101101011011001011001100110010
146
11101111000010000011101011000011101100001111111100100011011100101000101010010100001100101010110101001101001101001100110011001010101101010011010101
148
000010101010010011101010101...

output:

61691330
49995812
22369621
2097151
22369605
5655706
22369621
16842240
26516068
6463833
88647917
44739114
9587953
2081023
1048511
32506176
32898816
2175
5850
29358080
49990092
12
8607
4190208
22369749
523264
22369621
99990001
31489792
16515583
50001753
4351
1531
16515071
33554431
44739114
8310
8228
3...

input:


output:

140

result:

ok m = 140

Test #28:

score: 12
Accepted
time: 5ms
memory: 3908kb

input:

1000
242
00101000100001010101101010000010000000000100010000010011101110110111101011010101001101001010101100110101010011010101001011010011001011001011001010110101010100110101001101001100110010110010101011001010110101001010110011010100101100110011010100
110
00000010111101111101000000010000010010001010...

output:

19290547
4194303
49990940
50006025
82213661
99996733
8388600
99992197
4194272
3145728
33554432
3583
28517548
50004217
258048
1032319
9437183
23410100
22369621
262016
26744824
89478485
524351
23958363
16777087
4877
33553400
44739114
33545216
6142
44214954
99995551
44739306
22369557
22369365
1191050
7...

input:


output:

140

result:

ok m = 140

Test #29:

score: 12
Accepted
time: 8ms
memory: 4200kb

input:

1000
98
11101011110101010111001010000101101110110000110111011100000100111100001110101011001011010101010011
124
1111010100100101000010001110110110110000111100100001010000101001000010000011111110110010101100101010110011001100110100110010
250
111101010110001010010100000010000100100010001000001111000011...

output:

12148616
36960772
33554430
1
26308868
89478485
99993925
1920
33423360
44739242
99996882
16
16
4178175
54136687
33550336
44739242
22107989
99993755
44739242
22369621
33489023
99992679
99990455
44739258
69602424
130560
4013
50009628
59369637
17825791
28461862
49996420
30758229
2031616
91627683
9999929...

input:


output:

140

result:

ok m = 140

Subtask #5:

score: 15
Accepted

Test #30:

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

input:

1000
124
1101000100011111011101010101101011111101101010010000100001001010101111000100100010000010111011101110111110111111011101110100
146
00001101100010101111001001010011101111110101010111110111010000111110101011110111111101111010101101101111010001001110111100010011111011001010110100
266
00100100100...

output:

4546432148
30413720335
64676441097
14822382585
53698083736
74089682971
27607704419
15413953650
610991477
57301157297
86072616834
28923701798
37924130772
64471546997
69848357389
72672019255
11349616347
15013636082
23754476592
79891878197
58618203138
11772720766
1344307407
99482310933
42479246869
3281...

input:


output:

140

result:

ok m = 140

Test #31:

score: 15
Accepted
time: 4ms
memory: 3900kb

input:

1000
242
00001111010100000010000001010010010000100100001110000000110101011010101010101010100010010011011101101100010101010000010011101110110000110111000101010000110101010010101010101101001101010101001100110011010100110010101010101010110101010100101100
150
01010111011110101111000011101110111010100110...

output:

81121541265
67824082007
12814662619
11913434985
5478389391
23715785263
87267905905
58842463115
35294626604
27898718567
1037360815
92968125883
98452935282
32337222080
22349606935
32673329459
78326460781
84811974591
85320335499
82887668869
13171557568
29478862190
51697745861
28561201308
57555237849
80...

input:


output:

140

result:

ok m = 140

Test #32:

score: 15
Accepted
time: 7ms
memory: 3892kb

input:

1000
184
1011000011101100101001111011100100101011011011011101111111000100010110101001001011111011101010001000111111010110110110101111001000111010110101010100101011001100101100101100110010110100
234
111010010011110010010000010100010011101011000100101011110100010100010011101101101011001000100010100001...

output:

72763468402
35919173078
89821673065
83626819546
15516395517
93439771184
48769891560
85622835729
33452865411
5551802860
57588497949
25703640559
31522355965
50962164217
59442352877
288570071
32336815864
50975416871
99958378026
78724287780
12032607775
87729057614
64950115324
47227561883
8925151818
4589...

input:


output:

140

result:

ok m = 140

Test #33:

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

input:

1000
250
0100010011110101111011111111110000100000100101000000100011010111110101111110101000010110110010001000001110111101101011001000010101001010101010101101010101010011001100110010101011010100110011010100101101001100110010101101010010110010101101001101010100
178
111111101100010000010011010101110101...

output:

82238727287
71906507210
49571464593
37906706994
63771066149
58647519519
70217588781
88447485096
25138813519
96362938257
1838163037
53422801285
2336254259
75340440232
19014710500
64979623347
4133460007
89985950220
19454384597
27914761527
23866302679
56150609088
35282171373
45211350832
51454565298
182...

input:


output:

140

result:

ok m = 140

Test #34:

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

input:

1000
160
0101000000101000100000100100000100101111101111000001001110110010101001110100100010000010010010100010111010110001010101011011101011000111000010100011010010101011
208
010111000010111100001111110100010110100100110101011101000100001000010100111110111111110000101111001001000101101011010010101010...

output:

69188543327
99431485329
89455533767
64803853758
90784816293
2414630217
34075535309
11915710619
82246855931
72360562937
8510675849
59048593061
92734676478
57613782831
73557293576
80056754380
15411760095
91465444920
54790392370
69868221516
10010356646
8602470848
27786016668
9379849080
24213801618
3998...

input:


output:

140

result:

ok m = 140

Test #35:

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

input:

1000
212
10010010010001010000001001001000100100001011010111011011011011000001000101110111101000010111010000010101000010100000100011101010100101000100100011001011001011001010101010110011001100101010101011001101010010110010
212
01001101011101111011101011110110101111011011101010101010010010100000111010...

output:

100000000000
99999999999
99999999998
99999999997
99999999996
99999999995
99999999994
99999999993
99999999992
99999999991
99999999990
99999999989
99999999988
99999999987
99999999986
99999999985
99999999984
99999999983
99999999982
99999999981
99999999980
99999999979
99999999978
99999999977
99999999976...

input:


output:

140

result:

ok m = 140

Test #36:

score: 15
Accepted
time: 4ms
memory: 4100kb

input:

1000
212
11000100100000100100100101001000000101000011101111101100010010000100101101011111010101110010100000111100010000000010001000111010010010100010001010110011001101001011001011010011001100101011001100101011001101010100
212
10110000010101000010000010010101001001010001001010001111011111000000010011...

output:

100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
100000000000
1...

input:


output:

140

result:

ok m = 140

Test #37:

score: 15
Accepted
time: 9ms
memory: 4200kb

input:

1000
64
0100101010110101010101001100110011001011001101001011010100101011
220
1110111111011100010000001011011011011100101000010101011100101000100000100011110111000101001001010100111100000001011111010001010101110101001100110011010101001101001100101101010101010101001011001101001101001011001010101100
23...

output:

63
45812525738
60845370026
16777215
6949788660
82187441051
491520
68719435776
99999690568
47640940064
23040709909
49999973510
20021061229
37223049899
22906494293
23443363141
22906492245
22906492245
7286862438
268431360
268435487
23443363157
45804595882
262544
134218751
251660
17179836416
2147483647
...

input:


output:

140

result:

ok m = 140

Test #38:

score: 15
Accepted
time: 4ms
memory: 3960kb

input:

1000
162
001011011101011010010100000110110101110110111010101000100000000100101111101000010001010100110011010100110100110101010101001101010011010010110010110100110011001010
246
0011011011000000100010010100100010101001110010010001001101110110100100001101100101000100100011101110110100010010101011101110...

output:

66978303
4294969599
2093055
34357673984
22367393362
8573190016
1023
50000233241
49999817456
99999994623
44011
16744448
1159
34359736319
22906492245
158782
45814033066
22906500437
34359706112
14181780068
8589930496
57266230549
45810887338
22906492245
532741888
25081891007
22906492245
34359214080
4581...

input:


output:

140

result:

ok m = 140

Test #39:

score: 15
Accepted
time: 8ms
memory: 3848kb

input:

1000
148
1100010010101011011100010001001011011111011110110010000001000010100111001001000010000101000011110100100100001000100101001100101101010010101011001010
272
010010100011110110101000100000110101101101101110101011011111000010001010110111101100100100010111010000110110110000111101110110101100000010...

output:

2139160448
49999757899
238807
34357641212
45829761706
24541711179
49999832079
88259
45812984490
50000279655
99999966813
33826996479
44105735464
140738
528547328
32639
97067
34359214112
22905443668
49999916961
49999853665
99999707573
69657193545
33294320127
6193865726
283100
125332
20243500251
343513...

input:


output:

140

result:

ok m = 140

Subtask #6:

score: 60
Accepted

Test #40:

score: 60
Accepted
time: 10ms
memory: 3828kb

input:

1000
276
101001000101110010100000110111010101001000010001000101010000101000101110110100100101101010100100001111010100000100111111011101111011111101010111110010000011111101110010010010001001000110100010001011011101110000001000001110110111000100101011101110101010110111101101010100101100
276
0000001010...

output:

312554355143507232
865516701326178861
874321631501645440
572785971002627108
937898514787860024
182722095583952752
652610043852154720
550392030012398829
356057473025435267
21077804084383226
138795177332861352
943896008025622520
521009129476832407
121289804801449926
651679600604068722
7709026160230652...

input:


output:

140

result:

points 1.0 m = 140

Test #41:

score: 60
Accepted
time: 5ms
memory: 3868kb

input:

1000
276
000001010010100011101010001000010011101011111010110110101000100000100010101110111100100000111111011100001001010101010110101111000010000100010000010000111110101100101010101001000100100010111000111111011101101000101001010001010101101000010010100000001001001110100101001000111011
268
0010000011...

output:

999808955226945321
492421101324085991
819728168513811817
341720831639139956
697173002350197135
7248092584279565
755498070795533222
212066373059208537
576256754721357359
372053622367283077
616744378232527874
101213629615479726
584285125073319333
946482339048914052
911515356595444347
13410636768331775...

input:


output:

140

result:

points 1.0 m = 140

Test #42:

score: 60
Accepted
time: 7ms
memory: 3928kb

input:

1000
278
00110101110111101000001000110111010000101001001000101101110010010101110001001111110000001000010001010011011011010100100011011100010010100010001011110111010010000011011011011110111010000100110111111101111101010000000101010000101010111011110100101000100011011110110000110010101100
278
00101000...

output:

322389311653225437
475532879229955235
316997675082208320
985229433219235023
713118209280458810
144483917184964855
554842550748116430
618211131089512189
157451789128454862
566601643859496763
363823674791473357
706126529122622871
54833827468515740
991449785775002874
549475771247060836
6017482276811443...

input:


output:

140

result:

points 1.0 m = 140

Test #43:

score: 60
Accepted
time: 5ms
memory: 3836kb

input:

1000
278
11110111000011011011010100100101000101110111110110101010101000101111000001010111010100010011011100001101110110110010010000101101101100001110100100010000010000010011110000111110110100010101001010100010101111000101000010111101111100010101011011000011110000111111101011110111010011
280
00111010...

output:

902262028281859942
488043209805133165
198140363886320253
249381429748211052
947470859901234140
886250861424986739
760932281800698696
768015946313335377
642912304757199116
576157808218221259
939823375737729086
505870744433720338
712015939663914407
78540598183603047
408251255557107110
9754621886872300...

input:


output:

140

result:

points 1.0 m = 140

Test #44:

score: 60
Accepted
time: 10ms
memory: 3868kb

input:

1000
276
110110100010001001101111101000101101011111000001001001000100101110110101110111101100101001000100001001011100001011101011010010011011000100101010110101011010100011011101101010001111010110001101110010010101110111110000100010100001001111011111000110101011000101110110110101010010
272
0000000010...

output:

659100989758243692
445383036076185499
809599275381971432
911559544207628827
815799885865697013
906476486285350781
552175841460743656
806764971916118273
2894343659455343
638736576634992678
42386072345574043
410457935218168325
219071516708662591
758870514120554878
320092175710526428
313121976245851027...

input:


output:

140

result:

points 1.0 m = 140

Test #45:

score: 60
Accepted
time: 11ms
memory: 4168kb

input:

1000
280
1101000010111101111010110111000011111010101110111111010100000001001110100011111101010111000100100101010001001010100100111101111110110101011011111110100010010010111110100100010100000010111100000100101011011010110111001001010010000000100001010000111101110111110010001000110011010010
272
101101...

output:

582052873910414242
248661772680198124
419421146298088548
493012384345160474
406630988761146667
414462588641864114
297073568893964172
550940801029714062
164703383876320638
412132615405786381
541822677983525891
276373642095107979
695215184082917085
933830477843230958
631685317304355586
838834673979789...

input:


output:

140

result:

points 1.0 m = 140

Test #46:

score: 60
Accepted
time: 10ms
memory: 3864kb

input:

1000
280
1100001000111101101110110001001101011010001011011011110001000101011101011101110111111111101101001000001000101110010101110100100010110110111111010101000011101010110010101000101111101011010111011110110001000011111010100001001110111010110111000001001011111100100000101011110010110100
280
010010...

output:

701003404930888686
399736263244064145
28459989988259623
447144485561133834
988437135512054075
988042112632164796
172649249122024806
883668895104103303
188999560197916930
225517910385773556
750699500833521662
636000314304998531
626327070962171017
75458692868005385
27771041523300129
382931153791603191...

input:


output:

140

result:

points 1.0 m = 140

Test #47:

score: 60
Accepted
time: 0ms
memory: 4160kb

input:

1000
272
00101010001110101100101010101000100000101001000100001010010010000100101010111101100000100011110001010000101011110001001111101111110101101110001101101100010100001011110000110111111100001001001000111100000011101010010101001000111100001011110111010000010100101100110101010011
274
00010101101110...

output:

130849887051566539
537359141795020615
862469297016231998
414932569370685362
224538689279537302
602661864097763483
910192278696650979
666989971752856171
17950391787320695
946986770293305303
948629134288840126
93870719683077893
499938814406671850
631561144029779733
893284834760630530
12826458975587185...

input:


output:

140

result:

points 1.0 m = 140

Test #48:

score: 60
Accepted
time: 10ms
memory: 3836kb

input:

1000
276
110000111010110101111011011110001001001111101100101010001110110001000100000010000010001111111110101011101010101101111010101000110101110110101101000101101111101111011101111101111111011111010100010101010000000010000101001010010111000010111101110010001001011100010010101001010000
272
1111011100...

output:

978547570759349968
200919795322234990
955668575376362149
928098493368074005
287733299736453452
158315316345015305
101804519458499333
251185068629616783
36177029940780776
826338374771728744
453352169994017386
7969126640540357
175941162974768922
366781227558448488
42100942338257360
978238772968404570
...

input:


output:

140

result:

points 1.0 m = 140

Test #49:

score: 60
Accepted
time: 5ms
memory: 3872kb

input:

1000
280
1101000001001111010000101101101111110000101101110111001000101110001011011110110101111011010000100001010010111011110010010100111010100000111100001001000011010110101111011110110101101100000000110111101011110000111011101101111101001000101111011010010011011011110100110010110011010010
268
110000...

output:

327105005849345844
496635880636263072
411708277565120918
270065558767750316
306286259926389473
808031877988999294
743341214002116685
719441750906063888
75561849796915633
518262895465988503
79136545399694658
363581744132693665
129741562565858192
538285648946711544
348588758658478465
58879269625083490...

input:


output:

140

result:

points 1.0 m = 140

Test #50:

score: 60
Accepted
time: 2ms
memory: 3824kb

input:

1000
278
10110110111011101110111010000001010001110010101001000100010100111110110001001111101111010110101100001111010000101001010111101011000011110000010011101011110100100011101011110111010000000100100011011011010000010011111110101110100101110000101011101010010100110110101010110101010011
260
00000100...

output:

479798265039992512
220936204231966261
904833216286567218
73539497101601807
268941309788722582
363804022145478160
979862069484756597
817815751490440487
664656325314824454
206032188803692078
175168928213900127
409960650039604443
957221147764812900
334882801651091830
934563962043827972
8089017861151091...

input:


output:

140

result:

points 1.0 m = 140

Test #51:

score: 60
Accepted
time: 5ms
memory: 3896kb

input:

1000
278
01010110101101011010010001001010010000100011010110110111101010000101000000100000111101101011010101000100111101101101011011001000001000001000100001010011110000111001000100010111000101010001001111010010010100100110101100000101000100000001000011111101110000001100110010101010101010
280
11001010...

output:

211128179711291243
939117750366789764
378468538859252435
651450435511638142
990368149960392516
85290242430228251
900632142505212164
44214012724934768
428248260144755291
363319841148700409
347711332280795162
141046619582157063
722406552818499840
360887214567454278
366612710705501916
30721385408682571...

input:


output:

140

result:

points 1.0 m = 140

Test #52:

score: 60
Accepted
time: 3ms
memory: 3928kb

input:

1000
276
111011110001010010010011011111011100010001010110110110110010000110111011110010001001101101110000000101010100100000100010000100101000101010001000001111110000101111001000101011011100101001000001001001000011110000010101001101101100001000111111101101011100101000111010110111000100
276
0100001001...

output:

1000000000000000000
999999999999999999
999999999999999998
999999999999999997
999999999999999996
999999999999999995
999999999999999994
999999999999999993
999999999999999992
999999999999999991
999999999999999990
999999999999999989
999999999999999988
999999999999999987
999999999999999986
99999999999999...

input:


output:

140

result:

points 1.0 m = 140

Test #53:

score: 60
Accepted
time: 10ms
memory: 4148kb

input:

1000
276
110101011111010001010000110101011011110110101100010001011101010110100001010110101111101010001001010011110111010100010000010101001000100010000001000001001001000111011011000101001111000010111100101000000100010000111010100010010011110010000011101011110111110010010011011101110000
276
1101101101...

output:

1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
1000000000000000000
...

input:


output:

140

result:

points 1.0 m = 140

Test #54:

score: 60
Accepted
time: 10ms
memory: 3900kb

input:

1000
278
11011011101101100100010010001101101111010110100010110110111101111101000011101011100011011100000010101010000011111011110110111011011011110110100000100000101111111100010101010101010110111110101101010100010101001001010000100100010100000010111000110110111010100100111101000101010011
266
00111100...

output:

576460752303382544
346103352760283865
384309367225537877
245122275431109964
576460752269869088
999999999404082334
285996100333141760
576460477291298816
35993612646875136
384870118155703637
93266506704643492
999999999666695660
131008
72057594037919743
247024435593831579
999999999515649892
99999999944...

input:


output:

140

result:

points 1.0 m = 140

Test #55:

score: 60
Accepted
time: 7ms
memory: 4192kb

input:

1000
268
0001010010101011011111101000101101011101010101011100000010001000010000111100000010010010111011101110101001010100000101101111010000001110100000010001010100000010100011010101110110111011000010010000111101110111110010100010010110101110110000111011000010000010001111010101
276
000011110100100000...

output:

499999999362731397
379804118330725717
228374778660215605
1020
999999999551923729
576460752295034748
384870118155703637
999999999075157747
245787969813305749
384307202562020693
147018985357998996
288792228736810880
739308223
208567305
143835903599444223
174246025733908714
768614336404564650
144115188...

input:


output:

140

result:

points 1.0 m = 140

Test #56:

score: 60
Accepted
time: 0ms
memory: 3900kb

input:

1000
278
10101001101100100010101001111110110110000101011101111100100000100100001110101010100010100011110000001101101100010101001111011100100010101111110001000101010000111111111010100001001010010010001001010001001011101011110100000100111010010100101010110110110010100010001000000100101101
276
00000100...

output:

784017322558474384
384307168202282325
8388604
511
239336111
999999999162386160
792026465
576460752301325312
574206753466482688
289347616339001599
504682442775461376
576390381411762176
500000000429199773
567488464686170048
169279356711103844
68718428160
114117841979067801
239791791609403888
411739970...

input:


output:

140

result:

points 1.0 m = 140

Test #57:

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

input:

1000
208
0011110111010111110001001001001011011101110101110010100101110101101010110000111111101101110000110111111101011010110011010010110011001101001011010100101101010010101100110010101101010010110101001011001101001011
268
010101101101101101011111101111001000111110001000001011111101101110110101000011...

output:

807789569
500000000949772483
500000000150417465
999999999493880557
167520314714311883
144115188059078656
766362536590879402
134217472
360383371
420335965221246293
384307168202278229
567453553048682500
575897664911048704
500000000031872276
8989880874942719
768579152032475818
288230376151580672
999999...

input:


output:

140

result:

points 1.0 m = 140

Test #58:

score: 60
Accepted
time: 10ms
memory: 3976kb

input:

1000
268
1110111101101010110000100011110110101110110111011110101000010100010011011010111100000100010101101111011101010100001111101101110110110000101000110101011010100001001110111011101111001000010000010110111100100100001101110101101101111011111101110100010010001111111100101010
246
000011110111010001...

output:

288230376151710720
499007767
499999999519324425
500000000200749557
721187240
500000000517430470
1879048192
999999999637972923
285996100072513408
384258653817574245
236397908
4494837361401919
504
432204835329146880
89760186286593468
576458552206417920
540572418964471744
999999999854418697
38430936715...

input:


output:

140

result:

points 1.0 m = 140

Test #59:

score: 60
Accepted
time: 3ms
memory: 3892kb

input:

1000
262
0010100001010011101000101001000101110110100100001000001010110111000010110101101000111100010000101001001001001001010100101010010001001101101100010111011100100010010010111110101110111100010000111011011011000010001010001001110001001001010110100010010000000000101010
278
111010100000111101001001...

output:

119992631382137701
576460750155939840
384307168203330901
539971623
900095152
1073709055
768614336404564650
500000000072633387
312249608524092757
571974676276322240
999999999207521966
999999999583532812
720444733751041395
379522093598201173
70936023590272896
576425533571072000
207356211605573344
2053...

input:


output:

140

result:

points 1.0 m = 140

Extra Test:

score: 0
Extra Test Passed