QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90022#1283. Paper-cuttingAppleblue17RE 255ms74004kbC++146.0kb2023-03-21 22:48:352023-03-21 22:48:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-21 22:48:37]
  • 评测
  • 测评结果:RE
  • 用时:255ms
  • 内存:74004kb
  • [2023-03-21 22:48:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5,INF=1e9;
int T,n,m,ans[N];
char str[N];

int dat[N*8],*cur;
int *a[N],*vis[N];

bool checkrow(int x,int y){
	if(!x && !y) return 1;
	if(!x || !y) return 0;
	for(int j=1;j<=m;j++)
		if(a[x][j]!=a[y][j]) return 0;
	return 1;
}
bool checkcol(int x,int y){
	if(!x && !y) return 1;
	if(!x || !y) return 0;
	for(int i=1;i<=n;i++)
		if(a[i][x]!=a[i][y]) return 0;
	return 1;
}

int s1[N],cnt1,s2[N],cnt2;
int p1[N],p2[N];

int L[N],R[N],D[N],U[N];

int fx[4][2]={{0,-1},{0,1},{-1,0},{1,0}};

int L_,R_,U_,D_;
void dfs(int x,int y){
	if(vis[x][y]) return ;
	vis[x][y]=1;
	U_=min(U_,x),D_=max(D_,x);
	L_=min(L_,y),R_=max(R_,y);
	
	for(int t=0;t<4;t++){
		int nx=x+fx[t][0],ny=y+fx[t][1];
		if(nx>=1 && nx<=n && ny>=1 && ny<=m && a[nx][ny]) dfs(nx,ny);
	}
}

struct abc{
	int typ,l,r,L,R;
}p[N];
int id;
namespace task1{
	struct def{
		int typ,x,num;
	}q[N];
	bool operator <(def X,def Y){
		if(X.x==Y.x) return X.typ<Y.typ;
		return X.x<Y.x;
	}
	
	int id,ANS[N];
	void init(){
		id=0;
	}
	void ins(int typ,int x,int num){
		q[++id]={typ,x,num};
	}
	void solve(){
		sort(q+1,q+id+1);
		for(int i=1;i<=id;i++) ANS[i]=0;
		int s=0;
		for(int i=1;i<=id;i++){
			if(q[i].typ==1) s++;
			else ANS[q[i].num]=s;
		}
	}
}

int lim;
namespace task2{
	struct def{
		int typ,x,y,num;
	}q[N];
	bool operator <(def X,def Y){
		if(X.x==Y.x) return X.typ<Y.typ;
		return X.x<Y.x;
	}
	
	int c[N];
	inline int lowbit(int x){
		return x & (-x);
	}
	inline void modify(int x){
		while(x<=lim) c[x]++,x+=lowbit(x);
	}
	inline int query(int x){
		int tot=0;
		while(x>0) tot+=c[x],x-=lowbit(x);
		return tot;
	}
	
	int id,ANS[N];
	void init(){
		id=0;
		for(int i=1;i<=lim;i++) c[i]=0;
	}
	void ins(int typ,int x,int y,int num){
		q[++id]={typ,x,y,num};
	}
	void solve(){
		for(int i=1;i<=id;i++) ANS[i]=0;
		sort(q+1,q+id+1);
		for(int i=1;i<=id;i++){
			if(q[i].typ==1) modify(q[i].y);
			else ANS[q[i].num]=query(q[i].y);
		}
	}
}

int main(){
	cin>>T;
	for(int T_=1;T_<=T;T_++){
		scanf("\n%d%d",&n,&m);
		lim=max(n,m);
		cur=&dat[0];
		for(int i=1;i<=n;i++) a[i]=cur,cur+=m+5;
		for(int i=1;i<=n;i++) vis[i]=cur,cur+=m+5;
		
		for(int i=1;i<=n;i++){
			scanf("\n%s",str+1);
			for(int j=1;j<=m;j++){
				a[i][j]=(str[j]-'0')^1;
				vis[i][j]=0;
			}
		}
		
		
		int mx;
		cnt1=cnt2=0;
		for(int i=1;i<=n;i++) s1[++cnt1]=0,s1[++cnt1]=i;
		s1[++cnt1]=0;
		int r=-1,c=-1;
		for(int i=1;i<=cnt1;i++){
			p1[i]=1;
			if(i<=r) p1[i]=min(r-i+1,p1[2*c-i]);
			while(i-p1[i]>=1 && i+p1[i]<=cnt1 && checkrow(s1[i-p1[i]],s1[i+p1[i]])) p1[i]++;
			if(i+p1[i]-1>r) r=i+p1[i]-1,c=i;
		}
		
		U[1]=1; mx=1;
		for(int i=2;i<=n;i++){
			int lim=i*2-1-p1[i*2-1]+1;
			if(lim<=2*mx) U[i]=1,mx=i;
			else U[i]=0;
		}
		D[n]=1; mx=n;
		for(int i=n-1;i>=1;i--){
			int lim=i*2+1+p1[i*2+1]-1;
			if(lim>=2*mx) D[i]=1,mx=i;
			else D[i]=0;
		}
		
		for(int i=1;i<=m;i++) s2[++cnt2]=0,s2[++cnt2]=i;
		s2[++cnt2]=0;
		r=-1,c=-1;
		for(int i=1;i<=cnt2;i++){
			p2[i]=1;
			if(i<=r) p2[i]=min(r-i+1,p2[2*c-i]);
			while(i-p2[i]>=1 && i+p2[i]<=cnt2 && checkcol(s2[i-p2[i]],s2[i+p2[i]])) p2[i]++;
			if(i+p2[i]-1>r) r=i+p2[i]-1,c=i;
		}
		
		L[1]=1;
		mx=1;
		for(int i=2;i<=m;i++){
			int lim=i*2-1-p2[i*2-1]+1;
			if(lim<=2*mx) L[i]=1,mx=i;
			else L[i]=0;
		}
		R[m]=1; mx=m;
		for(int i=m-1;i>=1;i--){
			int lim=i*2+1+p2[i*2+1]-1;
			if(lim>=2*mx) R[i]=1,mx=i;
			else R[i]=0;
		}
		
//		for(int i=1;i<=cnt1;i++) cout<<p1[i]<<" "; cout<<'\n';
//		for(int i=1;i<=cnt2;i++) cout<<p2[i]<<" "; cout<<'\n';
//		
//		cout<<"U: "; for(int i=1;i<=n;i++) cout<<U[i]<<" "; cout<<'\n';
//		cout<<"D: "; for(int i=1;i<=n;i++) cout<<D[i]<<" "; cout<<'\n';
//		cout<<"L: "; for(int i=1;i<=m;i++) cout<<L[i]<<" "; cout<<'\n';
//		cout<<"R: "; for(int i=1;i<=m;i++) cout<<R[i]<<" "; cout<<'\n';
		D[n+1]=0;
		for(int i=n;i>=1;i--){
			if(D[i]) D[i]=i;
			else D[i]=D[i+1];
		}
		R[m+1]=0;
		for(int i=m;i>=1;i--){
			if(R[i]) R[i]=i;
			else R[i]=R[i+1];
		}
		
		id=0;
//		p[++id]={1,17,20,1,1};
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(!a[i][j] || vis[i][j]) continue;
				L_=U_=INF,R_=D_=0;
				dfs(i,j);
				p[++id]={1,U_,D_,L_,R_};
			}
		}
		int sav=id;
		
		for(int i=1;i<=n;i++){
			if(!U[i] || !D[i]) continue;
			for(int j=1;j<=m;j++){
				if(!L[j] || !R[j]) continue;
				p[++id]={2,i,D[i],j,R[j]};
			}
		}
		
//		for(int i=1;i<=id;i++){
//			cout<<" "<<p[i].typ<<" "<<p[i].l<<","<<p[i].r<<" "<<p[i].L<<" "<<p[i].R<<'\n';
//		}
		
		for(int i=1;i<=id;i++) ans[i]=0;
		
		for(int fl=0;fl<=1;fl++){
			task1::init();
			for(int i=1;i<=id;i++){
				if(p[i].typ==1) task1::ins(1,p[i].r,i);
				else task1::ins(2,p[i].l-1,i);
			}
			
			task1::solve();
			for(int i=1;i<=id;i++) ans[i]+=task1::ANS[i];
			
			for(int i=1;i<=id;i++){
				p[i].l=N-p[i].l,p[i].r=N-p[i].r;
				swap(p[i].l,p[i].r);
			}
		}
		
		for(int fl=0;fl<=1;fl++){
			task1::init();
			for(int i=1;i<=id;i++){
				if(p[i].typ==1) task1::ins(1,p[i].R,i);
				else task1::ins(2,p[i].L-1,i);
			}
			
			task1::solve();
			for(int i=1;i<=id;i++) ans[i]+=task1::ANS[i];
			
			for(int i=1;i<=id;i++){
				p[i].L=lim+1-p[i].L,p[i].R=lim+1-p[i].R;
				swap(p[i].L,p[i].R);
			}
		}
		
		for(int fl1=0;fl1<=1;fl1++){
			for(int fl2=0;fl2<=1;fl2++){
				task2::init();
				
				for(int i=1;i<=id;i++){
					if(p[i].typ==1) task2::ins(1,p[i].r,p[i].R,i);
					else task2::ins(2,p[i].l-1,p[i].L-1,i);
				}
				
				task2::solve();
				for(int i=1;i<=id;i++) ans[i]-=task2::ANS[i];
				
				for(int i=1;i<=id;i++){
					p[i].L=lim+1-p[i].L,p[i].R=lim+1-p[i].R;
					swap(p[i].L,p[i].R);
				}
			}
			for(int i=1;i<=id;i++){
				p[i].l=lim+1-p[i].l,p[i].r=lim+1-p[i].r;
				swap(p[i].l,p[i].r);
			}
		}
		
		int anss=INF;
		for(int i=sav+1;i<=id;i++){
			anss=min(anss,sav-ans[i]);
//			cout<<sav-ans[i]<<" ";
		}
//		cout<<'\n';
		cout<<anss<<'\n';
	}
	
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3508kb

input:

3
2 5
11001
11001
5 7
1001100
0110011
0101101
0010010
1000000
3 2
11
11
11

output:

1
4
0

result:

ok 3 tokens

Test #2:

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

input:

100000
3 3
010
101
101
4 2
10
10
10
10
4 2
11
00
00
11
7 1
1
0
0
1
1
0
0
6 1
1
0
0
1
1
1
5 2
11
00
00
11
11
10 1
1
0
0
0
0
0
0
0
0
1
9 1
0
0
0
0
0
0
0
0
0
10 1
1
1
1
1
1
1
1
1
1
0
9 1
0
0
0
0
0
0
1
1
0
1 10
0010000100
7 1
0
0
0
0
0
0
0
4 2
00
00
00
00
7 1
0
1
0
0
0
0
1
10 1
1
0
0
0
0
0
0
0
0
1
9 1
1...

output:

3
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
2
2
1
1
1
0
1
0
2
1
1
1
1
2
1
0
2
2
2
1
2
1
2
2
1
0
1
1
1
2
1
1
1
1
1
1
2
0
1
1
1
1
1
1
1
1
0
3
2
1
3
1
1
3
1
1
1
2
1
1
1
1
1
3
1
1
2
0
1
1
1
2
2
1
1
1
1
2
2
1
2
2
3
2
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
2
2
2
1
1
5
1
1
1
2
1
1
2
2
2
2
2
1
1
1
2
2
2
1
1
2
2
1
3
1
1
2
1
...

result:

ok 100000 tokens

Test #3:

score: 0
Accepted
time: 116ms
memory: 3520kb

input:

10000
65 1
1
0
1
0
1
1
1
1
1
0
0
1
1
1
0
1
1
0
1
0
1
0
1
0
1
1
1
1
0
1
0
1
1
0
1
0
0
1
0
1
1
0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
0
1
1
0
1
0
0
1
0
81 1
0
0
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
0
0
0
1
0
0
0
0
1
0
1
0
1
0
1
0
1
1
0
1
1
1
0
0
...

output:

17
17
2
4
4
11
2
3
5
4
4
9
8
5
5
6
2
7
5
8
1
3
1
12
3
1
3
9
4
9
1
4
1
5
4
3
9
2
3
4
3
5
7
7
9
10
10
3
4
1
3
13
7
11
11
14
20
4
6
3
5
3
11
5
9
2
4
9
8
10
8
5
6
5
11
7
2
4
3
6
3
4
9
2
7
4
9
5
4
5
1
2
11
2
2
2
15
3
12
3
6
3
3
11
7
4
12
4
17
4
5
5
1
8
25
3
10
4
5
9
1
3
5
2
4
3
13
4
4
8
7
9
9
1
9
3
1
2
8...

result:

ok 10000 tokens

Test #4:

score: 0
Accepted
time: 87ms
memory: 3672kb

input:

1000
977 1
1
1
1
1
1
1
0
0
1
1
0
0
0
1
0
1
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
1
1
0
0
1
0
1
0
1
1
1
1
1
0
0
1
0
0
0
1
0
0
1
1
1
0
1
0
0
0
1
1
1
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
1
1
0
0
0
1
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
0
1
0
0
1
0
0
0
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
0
0
1
0
0
1
1
0...

output:

102
167
21
25
74
28
12
62
62
42
22
88
14
77
147
11
47
89
18
48
40
6
44
235
22
130
118
31
19
60
117
42
10
2
99
36
87
9
143
37
73
67
25
12
37
28
13
54
31
90
47
108
12
107
27
18
6
20
3
29
52
89
49
17
30
13
12
41
52
49
19
117
33
10
63
32
65
35
19
16
19
28
64
67
68
34
103
46
31
67
22
41
117
27
113
112
42...

result:

ok 1000 tokens

Test #5:

score: 0
Accepted
time: 84ms
memory: 4600kb

input:

100
8148 1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0...

output:

681
33
1156
568
237
528
311
229
1604
547
872
271
794
491
557
322
241
633
807
304
160
435
636
355
604
95
27
962
160
761
24
23
711
294
356
14
472
207
428
2371
539
1007
201
140
158
352
162
188
437
771
1286
1003
67
560
592
1002
408
238
71
74
359
1736
717
630
462
581
790
745
80
656
562
441
737
838
322
32...

result:

ok 100 tokens

Test #6:

score: 0
Accepted
time: 114ms
memory: 14476kb

input:

10
92831 1
0
1
0
0
0
1
0
0
1
0
1
1
0
1
0
0
1
0
1
1
0
1
1
1
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
1
0
0
0
0
1
0
1
0
0
1
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
1
0
0
0
1
1
0
1
1
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
1
0
0
0
1
0
1
1
1
0
1
0
0
1
0
1
0
1
1
0
1...

output:

5125
5258
4511
3428
198
5218
11694
9294
13007
1583

result:

ok 10 tokens

Test #7:

score: 0
Accepted
time: 100ms
memory: 13644kb

input:

10
53270 1
0
1
1
0
1
1
1
1
0
1
0
0
1
1
1
0
0
0
1
0
1
0
1
1
1
0
0
1
0
1
1
1
1
0
0
1
1
0
1
1
0
1
1
0
0
0
1
0
0
0
1
0
1
1
0
1
1
1
0
0
0
1
0
1
1
0
0
1
0
0
0
1
1
1
1
0
1
1
1
0
1
1
1
0
1
1
1
1
1
0
0
0
1
1
0
1
1
1
1
1
0
0
0
1
1
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
0
0
1
0
1
1
1
0
0
1
1
1
0
0
1
0
1
1
0...

output:

6730
5017
389
2178
4679
5753
17391
4823
4599
1961

result:

ok 10 tokens

Test #8:

score: 0
Accepted
time: 114ms
memory: 28116kb

input:

1
1000 1000
011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110...

output:

8

result:

ok "8"

Test #9:

score: 0
Accepted
time: 158ms
memory: 28540kb

input:

1
1000 1000
010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010...

output:

41761

result:

ok "41761"

Test #10:

score: 0
Accepted
time: 255ms
memory: 74004kb

input:

1
1 1000000
011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110...

output:

2

result:

ok "2"

Test #11:

score: 0
Accepted
time: 180ms
memory: 62204kb

input:

1
1 1000000
010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010...

output:

196419

result:

ok "196419"

Test #12:

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

input:

1
2 500000
0110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100...

output:

4

result:

ok "4"

Test #13:

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

input:

1
2 500000
0100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100...

output:

242787

result:

ok "242787"

Test #14:

score: 0
Accepted
time: 56ms
memory: 15860kb

input:

1
1000 1000
001110010110101011110111111111111001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011000011000010011001000011000011...

output:

1964

result:

ok "1964"

Test #15:

score: 0
Accepted
time: 36ms
memory: 15604kb

input:

1
1000 1000
110111101111100011000110100110100000111100101011101010010001000101110101000101011101101111011001011100001011001101101101101101101101101000000101101101101101101101101101101101101101101101101000000101101101101101101101101101101101101101101101101000000101101101101101101101101101101101101101...

output:

31620

result:

ok "31620"

Test #16:

score: 0
Accepted
time: 41ms
memory: 14108kb

input:

1
1000 1000
001101100000000000000001100110000000000000000111100000000000000001100110000000000000000111100000000000000001100110000000000000000111100000000000000001100110000000000000000110111101100000000000000001100110000000000000000111100000000000000001100110000000000000000111100000000000000001100110...

output:

15347

result:

ok "15347"

Test #17:

score: 0
Accepted
time: 30ms
memory: 13884kb

input:

1
1000 1000
100100111100100100111100100000010011110010010011110011111100111100100100111100100000010011110010010011110011001111001001001111001000000100111100100100111100111111001111001001001111001000000100111100100100111100100100110010010011110010010011110010000001001111001001001111001111110011110010...

output:

11049

result:

ok "11049"

Test #18:

score: 0
Accepted
time: 35ms
memory: 15044kb

input:

1
1000 1000
110011111111110011111111110011101101110011111111110011111111110011001100111111111100111111111100111011011100111111111100111111111100110111101100111111111100111111111100111011011100111111111100111111111100110011001111111111001111111111001110110111001111111111001111111111001111001111111111...

output:

29274

result:

ok "29274"

Test #19:

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

input:

1
2 500000
1110011110101110101010111000001111010001010011111011100010010101111111100011100100110000110100000011111011001100110111011100101000001001101001010001100000101101100110011100100010001100001000110001011100111101010100000101010010101100100111110010011100101011001011001000110110001100100110110...

output:

110436

result:

ok "110436"

Test #20:

score: 0
Accepted
time: 71ms
memory: 30364kb

input:

1
2 500000
0010101010101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

74967

result:

ok "74967"

Test #21:

score: 0
Accepted
time: 25ms
memory: 15996kb

input:

1
10 100000
011001110011010111100111000010101101110101100001010100011000100111110100101101011011001000111101001100101100001111101011000111111011001010110101101110111011111011011110010101011010010111010000100001111100111111010100111110011011101001001010000101001100011011010011011100111100011001110011...

output:

4288

result:

ok "4288"

Test #22:

score: 0
Accepted
time: 46ms
memory: 19776kb

input:

1
5 200000
0000011000110110110101000110110111110001000011011110001111111100010101010010111111011010001111001011000111111011101111111110010101011000001111010110001000000010101001100001100100110110101100000010100011110100010001001110100011101100110010111110001111011001010101101110110110011001110111101...

output:

22390

result:

ok "22390"

Test #23:

score: 0
Accepted
time: 37ms
memory: 24780kb

input:

1
3 333333
0011101010011000011110000111111000011110000000011110000111111000011110000000011110000111111000011110000000011110000111111000011110000110110110000111100001111110000111100000000111100001111110000111100000000111100001111110000111100000000111100001111110000111100001100110000111100001111110000...

output:

17650

result:

ok "17650"

Test #24:

score: 0
Accepted
time: 85ms
memory: 20736kb

input:

1
20000 50
01111000010000101101000010110110011011010000101101
10000111101111010010111101001001100100101111010010
10000111101111010010111101001001100100101111010010
10000111101111010010111101001001100100101111010010
01111000010000101101000010110110011011010000101101
1000011110111101001011110100100110...

output:

3184

result:

ok "3184"

Test #25:

score: 0
Accepted
time: 93ms
memory: 21792kb

input:

1
25000 40
0000101100110100001011001101000101011101
0000101100110100001011001101000101011101
1111010011001011110100110010111010100010
1111010011001011110100110010111010100010
0000101100110100001011001101000101011101
0000101100110100001011001101000101011101
0000101100110100001011001101000101011101
11...

output:

23804

result:

ok "23804"

Test #26:

score: 0
Accepted
time: 51ms
memory: 18984kb

input:

1
33333 30
010000011110000001111000000100
010000011110000001111000000100
101111100001111110000111111011
010000011110000001111000000100
101111100001111110000111111011
101111100001111110000111111011
010000011110000001111000000100
101111100001111110000111111011
101111100001111110000111111011
1011111000...

output:

22032

result:

ok "22032"

Test #27:

score: 0
Accepted
time: 67ms
memory: 23536kb

input:

1
100000 10
0000000010
1111111101
1111111101
0000000010
0000000010
1111111101
0000000010
1111111101
1111111101
0000000010
0000000010
0000000010
1111111101
1111111101
0000000010
0000000010
1111111101
1111111101
0000000010
1111111101
1111111101
1111111101
0000000010
1111111101
1111111101
0000000010
11...

output:

29876

result:

ok "29876"

Test #28:

score: -100
Runtime Error

input:

1
1000000 1
1
0
0
0
0
0
1
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
1
1
0
0
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
...

output:


result: