QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#653950#9464. 基础 01? 练习题Nesraychan40 1287ms59708kbC++143.9kb2024-10-18 20:53:242024-10-18 20:53:26

Judging History

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

  • [2024-10-18 20:53:26]
  • 评测
  • 测评结果:40
  • 用时:1287ms
  • 内存:59708kb
  • [2024-10-18 20:53:24]
  • 提交

answer

#include<bits/stdc++.h>
#define IL inline
#define reg register
#define N 50050
#define M 200200
#define mod 998244353
IL int read()
{
	reg int x=0; reg char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x;
}

IL int Add(reg int x,reg int y){return x+y<mod?x+y:x+y-mod;}
IL int Sub(reg int x,reg int y){return x<y?x-y+mod:x-y;}
IL void Pls(reg int &x,reg int y){x=Add(x,y);}
IL void Dec(reg int &x,reg int y){x=Sub(x,y);}
IL int Mul(reg int x,reg int y){long long r=1ll*x*y; return r<mod?r:r%mod;}

bool ok[16][N][2];
int n,q,p[N][2],ip[N][2];
char s[N];
int pre[N],pw[N],ipw[N];

IL bool chk(reg bool x,reg char c)
{
	if(c=='?')return 1;
	return x?c=='1':c=='0';
}

int wr[N],wl[N];

struct Segment
{
	
#define ls (o<<1)
#define rs (o<<1|1)
#define mid (l[o]+r[o]>>1)

int l[N<<2],r[N<<2],val[N<<2],sum[N<<2],tag[N<<2];

void build(reg int o,reg int L,reg int R)
{
	l[o]=L,r[o]=R;
	if(L==R)val[o]=wl[L];
	else build(ls,L,mid),build(rs,mid+1,R),val[o]=Add(val[ls],val[rs]);
}

IL void pushup(reg int o){sum[o]=Add(sum[ls],sum[rs]);}
IL void apply(reg int o,reg int k){Pls(tag[o],k),Pls(sum[o],Mul(val[o],k));}
IL void pushdown(reg int o){if(tag[o])apply(ls,tag[o]),apply(rs,tag[o]),tag[o]=0;}

void modify(reg int o,reg int L,reg int R,reg int k)
{
	if(L<=l[o]&&r[o]<=R)return apply(o,k);
	if(L>r[o]||l[o]>R)return;
	pushdown(o),modify(ls,L,R,k),modify(rs,L,R,k),pushup(o);
}

int query(reg int o,reg int L,reg int R)
{
	if(L<=l[o]&&r[o]<=R)return sum[o];
	if(L>r[o]||l[o]>R)return 0;
	return pushdown(o),Add(query(ls,L,R),query(rs,L,R));
}

#undef ls
#undef rs
#undef mid
		
}A,B;

struct Opt{int l,r,w;};
struct Ques{int l,w,id;};
std::vector<Opt>vec[N];
std::vector<Ques>shelf[N];
int ans[N];

IL void slack(reg int lx,reg int rx,reg int ly,reg int ry,reg int w)
{
	if(lx>rx||ly>ry)return;
	vec[rx].push_back({ly,ry,w});
	if(lx>1)vec[lx-1].push_back({ly,ry,mod-w});
}

IL int min(reg int x,reg int y){return x<y?x:y;}

main()
{
	n=read(),q=read(),scanf("%s",s+1);
	pw[0]=ipw[0]=1;
	for(reg int i=1;i<=n;++i)pre[i]=pre[i-1]+(s[i]=='?');
	for(reg int i=1;i<=n;++i)pw[i]=Mul(pw[i-1],2),ipw[i]=Mul(ipw[i-1],mod+1>>1);
	for(reg int i=1;i<=n;++i)ok[0][i][0]=chk(0,s[i]),ok[0][i][1]=chk(1,s[i]);
	for(reg int o=1,i,j;o<16;++o)for(i=1;i+(1<<o)-1<=n;++i)for(j=2;j--;)
		ok[o][i][j]=ok[o-1][i][j]&&ok[o-1][i+(1<<o-1)][!j];
	for(reg int i=1,j,x,y,o;i<=n;++i)for(j=2;j--;)
	{
		x=i,y=j;
		for(o=16;o--;)if(x+(1<<o)-1<=n&&ok[o][x][y])y^=1,x+=1<<o;
		p[i][j]=x-i;
	}
	for(reg int i=1;i<=n;++i)ok[0][i][0]=chk(0,s[i]),ok[0][i][1]=chk(1,s[i]);
	for(reg int o=1,i,j;o<16;++o)for(i=n;i-(1<<o)+1>0;--i)for(j=2;j--;)
		ok[o][i][j]=ok[o-1][i][j]&&ok[o-1][i-(1<<o-1)][!j];
	for(reg int i=1,j,x,y,o;i<=n;++i)for(j=2;j--;)
	{
		x=i,y=j;
		for(o=16;o--;)if(x-(1<<o)+1>0&&ok[o][x][y])y^=1,x-=1<<o;
		ip[i][j]=i-x;
	}
	for(reg int i=1;i<=n;++i)wr[i]=pw[pre[n]-pre[i]],wl[i]=pw[pre[i-1]];
	for(reg int i=2,x,y;i<=n;++i)for(x=2;x--;)for(y=2;y--;)
		slack(i,i+p[i][x]-1,i-ip[i-1][y],i-1,1);
	for(reg int l=2,r,o,x,y;l<=n;++l)for(o=0;l+(1<<o)-1<n;++o)for(x=2;x--;)y=(o&1)^x,
		r=l+(1<<o)-1,slack(r+1,l+min(p[l][x],1<<o+1)-1,r-min(ip[r][y],1<<o+1)+1,l-1,mod-1);
	for(reg int i=1,l,r;i<=q;++i)
	{
		l=read()+1,r=read()+1,ans[i]=Mul(r-l+1,pw[pre[r]-pre[l-1]]);
		shelf[r].push_back({l,ipw[pre[l-1]+pre[n]-pre[r]],i});
	}
	for(reg int i=1;i<=n;++i)Pls(wr[i],wr[i-1]);
	A.build(1,1,n),B.build(1,1,n);
	for(reg int i=1;i<=n;++i)for(auto p:vec[i])
		A.modify(1,p.l,p.r,p.w);
	for(reg int i=1;i<=n;++i)
	{
		for(auto p:shelf[i])
		{
			Pls(ans[p.id],Mul(p.w,Mul(A.query(1,p.l,n),wr[i])));
			Pls(ans[p.id],Mul(p.w,B.query(1,p.l,n)));
		}
		for(auto p:vec[i])
		{
			A.modify(1,p.l,p.r,mod-p.w);
			B.modify(1,p.l,p.r,Mul(p.w,wr[i])); 
		}
	}
	for(reg int i=1;i<=q;++i)printf("%d\n",ans[i]);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 16944kb

input:

15 15
0???0??01???1??
2 14
0 9
6 10
1 14
1 14
0 12
5 14
6 7
0 6
4 14
1 12
10 10
0 14
1 12
4 7

output:

25883
2344
112
56425
56425
12963
4531
6
666
5212
11875
2
60786
11875
37

result:

ok 15 numbers

Test #2:

score: 10
Accepted
time: 2ms
memory: 16716kb

input:

15 15
011?1?0101??110
0 11
2 10
0 13
2 12
3 5
2 12
3 5
12 13
1 14
1 5
8 13
9 12
2 10
0 11
7 8

output:

803
285
952
732
23
732
23
3
940
48
69
37
285
803
3

result:

ok 15 numbers

Test #3:

score: 10
Accepted
time: 0ms
memory: 15392kb

input:

15 15
100110?1010?01?
9 9
6 11
1 4
0 13
7 7
9 13
3 14
0 0
0 13
0 12
0 10
6 11
4 8
3 13
0 13

output:

1
77
10
265
1
25
384
1
265
251
109
77
30
175
265

result:

ok 15 numbers

Test #4:

score: 10
Accepted
time: 2ms
memory: 17016kb

input:

15 15
??????0?0??????
8 10
0 14
9 12
2 13
1 6
7 12
0 13
6 14
0 11
0 14
4 14
5 14
0 8
4 5
1 13

output:

23
439848
146
41764
540
540
202272
3703
41802
439848
18776
8386
3703
12
92312

result:

ok 15 numbers

Test #5:

score: 10
Accepted
time: 0ms
memory: 17028kb

input:

15 15
?1??0?0??010?1?
3 14
4 5
0 14
0 13
4 8
12 13
1 5
5 8
11 13
3 3
1 12
0 2
5 14
11 12
4 12

output:

3128
6
15531
6994
99
6
101
73
12
2
2842
23
1305
6
522

result:

ok 15 numbers

Test #6:

score: 10
Accepted
time: 2ms
memory: 17408kb

input:

15 15
10????1001?11?1
0 14
0 5
0 14
5 13
4 9
10 14
6 13
0 14
1 9
0 13
6 13
1 11
1 13
9 13
4 5

output:

4184
279
4184
276
78
46
109
4184
531
3878
109
1446
3516
46
12

result:

ok 15 numbers

Subtask #2:

score: 0
Runtime Error

Test #7:

score: 0
Runtime Error

input:

20 200000
???10?10???????1????
1 19
2 17
5 19
6 19
6 15
5 19
1 11
0 15
4 6
3 16
10 13
12 18
16 16
0 15
7 14
2 11
14 19
9 16
0 18
11 16
7 13
1 17
5 18
7 7
6 10
4 17
5 19
2 9
0 16
1 19
5 14
4 19
0 11
0 16
15 19
0 12
1 15
4 17
13 16
3 14
4 13
5 13
3 10
0 19
2 17
6 18
0 18
7 10
3 18
10 14
1 13
0 16
0 19...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #13:

score: 0
Runtime Error

input:

50000 200000
011001101001011?10011001011010010110011010011001011?011010010110?0011001011001101?011?010?10100101100110100110010110011?1001011010011001011?10010?1?0?10100101101?01100101100110100110010110?001011001101001100101100?10100101101?0110?10110011010011001011010010110011010010110100110?10110100...

output:


result:


Subtask #4:

score: 5
Accepted

Test #19:

score: 5
Accepted
time: 69ms
memory: 20808kb

input:

50000 1
0101101001100101100110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010...

output:

132414834

result:

ok 1 number(s): "132414834"

Test #20:

score: 5
Accepted
time: 68ms
memory: 20956kb

input:

50000 1
1001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001...

output:

165181456

result:

ok 1 number(s): "165181456"

Test #21:

score: 5
Accepted
time: 64ms
memory: 20732kb

input:

50000 1
0010110011010011001011001101001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110011010011001011010010...

output:

384873

result:

ok 1 number(s): "384873"

Test #22:

score: 5
Accepted
time: 62ms
memory: 20916kb

input:

50000 1
1011001101001011010011001011010010110011010011001011001101001011010011001011001001011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011001101001100101101001011001101001011010011001011010...

output:

272208464

result:

ok 1 number(s): "272208464"

Test #23:

score: 5
Accepted
time: 66ms
memory: 20840kb

input:

50000 1
0110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100101101001100101100110100110010110100101100110101101001100100110010110100101100110100101101001100101101001011001101001100101100110100101101001100101100110100110010110100101...

output:

6615896

result:

ok 1 number(s): "6615896"

Test #24:

score: 5
Accepted
time: 58ms
memory: 20624kb

input:

50000 1
1001011010010101001100010110100011000110100111101000101100110001100101100000111010110010101100101010001110011111001100101000101101101010011011101100101101001011000110011001010110110000110100101101010010110110011010100110011010101001100100100110110010110100110100100110011010001001100101100010...

output:

41003648

result:

ok 1 number(s): "41003648"

Subtask #5:

score: 15
Accepted

Test #25:

score: 15
Accepted
time: 75ms
memory: 21248kb

input:

50000 1
01011010011000110100110010110010?1001?0001011001101?001011001101?0101101?011011001101001010?10100101101001100101?01100101010?101001100110?1011010011001011010??110011?1?011001?1100110?101101001100101100100110010110011100110100101001?1?0?00?100101101001011001101001011100?1010010110101101001011...

output:

111365458

result:

ok 1 number(s): "111365458"

Test #26:

score: 15
Accepted
time: 196ms
memory: 27584kb

input:

50000 1
0??0?1?10?????101??1??10??0???01001?????1??0?1?1?0101?????1?00???1?01???001?001?????0????1?01???0?110???1?0??10?0????10?????0???1????01???0011??0?1??1??????0???11???1???0????101?0?00101??0?10?00????10????????0?101101??110???1?001??????1????11??0?10???0?10???1?1?0??0???0?011?100?0????110?00??...

output:

825836622

result:

ok 1 number(s): "825836622"

Test #27:

score: 15
Accepted
time: 67ms
memory: 20996kb

input:

50000 1
11001101001100101101001011?01101001?11010011001011?1001011001101001100?01100110100101101001100101101001011001101001011?100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110011?1001??0101101001011001?01001100101100110100101101001100101101...

output:

624938164

result:

ok 1 number(s): "624938164"

Test #28:

score: 15
Accepted
time: 68ms
memory: 20932kb

input:

50000 1
1100101100110100101101001100101100110100110010110100101100110100101101001100101101001011001101001100101100110100101101001100101101001011001101001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001011001101001110100101101001100101101001...

output:

554863263

result:

ok 1 number(s): "554863263"

Test #29:

score: 15
Accepted
time: 90ms
memory: 22540kb

input:

50000 1
011001101?011001011010??0110?11010?1?0010110011010010110??01100101??01101001100101?010?1?1100?10100?0?1?10011?01??101001???00110?00?100??1?001?0100?011010?11?010?1010?101100110100??1?010011001011?0???1?0?1001011??0010110011010010110?0?110010???1001011?0110100?1?0?0110011011?010011?0??110?110...

output:

586569695

result:

ok 1 number(s): "586569695"

Test #30:

score: 15
Accepted
time: 1287ms
memory: 59708kb

input:

50000 1
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

329743182

result:

ok 1 number(s): "329743182"

Subtask #6:

score: 5
Accepted

Test #31:

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

input:

500 1000
011000100010010010010010110010101100101100101011010010011001101001011010011000010011010001011010000001100101100110100101101001001011010010110010110100101100111001100111010011010010110100110010110100101100110101000101100110100110010110100101100110100101101?01101101100101011001010010100110010...

output:

399
1770
1496
922
2273
23256
14888
21468
5050
11956
7336
16724
1640
23288
23076
5699
23296
556
10300
23036
2274
14904
344
958
8912
1922
372
16048
14908
2830
20496
748
17988
22832
21300
22324
17996
23792
3
17104
19492
474
8664
14960
19820
339
1402
12048
24060
20344
19324
20304
5254
3962
20340
1532
52...

result:

ok 1000 numbers

Test #32:

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

input:

500 1000
0010100100010011011101100101000010010110100101101001010010110101001?1001?0100100010010100010110110010111101110110001010010001011001010001010001001100101010011010110100110101111001001010101101000101100101100111011110110100100011010?101110010101111000101010000001110011010011000101100100101100...

output:

137
2544
479
2586
2756
19644
43352
2768
2692
12260
7068
92416
810
28
17768
91888
15836
15220
2618
327
3972
139
1504
7832
1069
12668
2576
45752
8904
2500
2582
94864
10356
95856
3446
15260
492
17572
15
43144
116
2898
81456
1738
3482
1130
4416
216
473
16884
2130
17812
39408
46312
3
2184
2774
224
7792
6...

result:

ok 1000 numbers

Test #33:

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

input:

500 1000
101001001?11011010010111100110010110101010010001111?10101010001101011011001110100101110011010011101011101110110100101011000001000110110000101000010010011?0100100100010001010001010011010011010001?011010011001110110101101011110100011100100101110011011010110101101010110100001101001110000101101...

output:

11024
63280
293632
2683
21432
712
3282
26296
3014
51856
3280
319520
156
19816
150912
1655
4506
675776
1212
2286
17620
1130
1066
28424
2306
9816
8080
2014
128320
11132
658880
740
324
2986
316832
678848
2560
4204
65440
2118
1138
5146
26664
64880
188
7392
1
145808
20808
568
9720
8996
6648
70352
35
1175...

result:

ok 1000 numbers

Test #34:

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

input:

500 1000
11010011001101101001011010110010100110110110?01001110101001010100111?010110011001001001101001110100101001100101101001001001101101001111100110100110010110011101100000100110111010001010011001101001011?1110011011101010010111001101101101101001010010001001011011001?010011001011110010?1100101?011...

output:

17104
869248
19664
56
198080
5168
12128
165472
65488
10
2716
913
385472
885248
50608
585
1760
14
356416
27440
185888
72336
1311
1794
438080
417472
1995
224
56432
270400
978
619
170624
402048
371520
416704
409728
85072
333632
1749
67568
26992
314688
1073
417216
406464
317248
897920
826368
52688
89459...

result:

ok 1000 numbers

Test #35:

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

input:

500 1000
01100011001011011100101100110100110010110100010011010110011010010010110100100110010011001011001101001011001101001?110100101100011010011001011001101001011011?01001011010000101100110100101101100110101100110100101101001100101100110010110011011000011011001011000011010010110100101100111001011001...

output:

165248
67
67800
12312
6642
173728
129888
3724
44680
59112
343
2285
2628
356640
5150
74520
651
7544
2299
23680
32548
3908
3919
337952
682
119008
123024
276
13148
33452
8254
70552
7082
799
10000
734
170048
367136
1470
398
2127
14100
763
182688
350560
804
62088
10108
365472
16168
11136
66
2347
56664
15...

result:

ok 1000 numbers

Test #36:

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

input:

500 1000
0110100110010110100101?00110100101101001100101100101101001100101100110100110010110101001011001101010100?100101101001011001101001100101100110100101101001100101101001011001101001011010011001011001101001100101101001011001101001100?0110011010110100110010110011010010110?001100101100110?001100101...

output:

393
233816
97288
178160
157752
521488
7155
2230
429616
78500
29384
192248
13936
22126
1952
103352
547504
165400
722032
39936
6616
1335584
3086016
65036
278
91692
619024
96060
62792
198512
642160
20596
627120
16676
1248096
356616
4303
79340
229120
570368
28
5047
11090
36716
1276320
1454432
17460
1160...

result:

ok 1000 numbers

Subtask #7:

score: 5
Accepted

Test #37:

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

input:

1000 2000
01100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010000110100101101001100101100110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110100110010110100101100110100101101001100101101001011001101001...

output:

3240
660160
644768
11858784
5776
12121
11513184
618368
615968
283884
287756
131958
136654
688720
16592
16444
585256
11476064
5050
591504
106490
114470
137158
1596
6031
5648304
11535200
111930
4278
11445472
51501
11529312
1770
50069
137226
8806
139654
5686
1891
22402
19931
138610
107750
51709
117090
...

result:

ok 2000 numbers

Test #38:

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

input:

1000 2000
010000101101000010011011001?111011010010101100110010110010010110011001011011110010111001011011001001110100101100110100000100110100100110110010101100110100110101100110100110010110010101101001100010011010101011010010100110?001001101110010110100100101011010011101001111110100110011010101011001...

output:

36508
1032896
1090624
6
9394
1164
216576
987968
6772
1376
21
26580
2206
39060
1938
2464
1002560
36308
3094
1063744
3042
39804
26020
3234
988480
34740
40740
2380
1100224
718
1063744
1060800
451648
34076
7342
3308
21716
9366
2066
38796
37828
463680
491392
473984
214720
26916
453824
24692
1027392
1702
...

result:

ok 2000 numbers

Test #39:

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

input:

1000 2000
0110100011010011001011100?01111010011001011001001011010100011001100100?011000011001011001101001011010011011001011100101100110100101101001100101100110100110010110100101110100110100110100110010011001011010001010100110010110011001100101101001010110100101010101001100101100101001011001101001100...

output:

989
34652
26512
40236
53876
51268
54464
54508
56676
33632
11404
17288
5168
34224
127692
42724
27324
917
59220
54360
45664
127748
39988
10760
55776
31204
54428
18512
51836
53996
122368
8964
125652
31764
3520
42364
41944
711
127780
127164
4244
45848
54996
3
123124
44644
11488
57544
51016
17984
30840
3...

result:

ok 2000 numbers

Test #40:

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

input:

1000 2000
01100110100110010110100101100110100101101001100001011010010110011010010110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110100110011010010110100110010110011010011001011010010110011010011001011001100101101001101001011010011001011010010110011010...

output:

231
2210
13703
1672512
55498
1907568
60184
1886352
261516
1756608
12639
12734
1409072
70520
1541952
11132
1685808
21
284252
11707
2669
1174
1490544
1802544
259548
1917168
2507
227164
9809
261516
332836
1572912
1207
331780
1751664
680576
2782
1913328
1942512
671608
332836
2257
1464624
1873472
1467072...

result:

ok 2000 numbers

Test #41:

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

input:

1000 2000
1101001100101001100101100110100101101001101100110100110010110011010010110100110010110100101100110100110010110100101101010011001011010001011001101001011010011001011010010011010010110011010010110010110100110010100110010110100101100110100110010110011010011?010110011010010110100110010110011010...

output:

4543
4732
134104
68168
2925
116176
133168
691200
114720
126656
4421
110752
1490496
324576
98536
114664
62472
3501
75488
129424
89408
29512
13318
91
123344
126504
100
205
60480
27052
128632
131200
1587456
1678656
83848
704832
69608
5263
128648
1457856
4577
128424
120936
1451968
705728
296032
1618368
...

result:

ok 2000 numbers

Test #42:

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

input:

1000 2000
00101101001011001101001011010011001011010?1011001101001100?01100110100101101001100101101?0101100110100101101001101100110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100010110100101100110100?1001011001101001011010011001011010010110011010010...

output:

34744992
4054912
38220
506120
8568032
4141440
4143808
3505952
800000
1927232
73860
17225056
31668
2151632
8740
19180
630
25944
4097440
2528896
629960
3380600
26564
815096
2068240
20092
34597920
3882640
34679232
34620
2037496
4066240
36092128
3244360
4002896
351
35317408
171072
178176
1755152
6892
35...

result:

ok 2000 numbers

Subtask #8:

score: 0
Runtime Error

Test #43:

score: 0
Runtime Error

input:

5000 100000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:


result:


Subtask #9:

score: 0
Runtime Error

Test #49:

score: 0
Runtime Error

input:

20000 100000
????????????????????????????0??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:


result:


Subtask #10:

score: 0
Runtime Error

Test #55:

score: 0
Runtime Error

input:

50000 200000
?01101001011001?01?011?010?1001101001?110?001?0?1?1?001101?0110?101?010??01100110?00?1001011001101001011??001?001?110100101100110100101?01?0110?1011?011010011001?1?0100??110011?100?01101001100?011010?10??00110100?1?0?0110?1101?01??1?10??10010?10?00101?00??0???101101?0???010110??1?10011?...

output:


result: