QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#54365#1773. Breaking BarsKING_UTAC ✓342ms13944kbC++203.8kb2022-10-08 02:17:222022-10-08 02:17:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-08 02:17:24]
  • 评测
  • 测评结果:AC
  • 用时:342ms
  • 内存:13944kb
  • [2022-10-08 02:17:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
//#define int ll
using uint=unsigned;
using ull=unsigned long long;

#define gnr(i,a,b)for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define rng(i, a, b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) rng(i,0,n)
template<class t>using vc=vector<t>;
template<class t>using vvc=vc<vc<t>>;
using vi=vc<int>;
#define a first
#define b second
#define mp make_pair
using vi=vc<int>;
#define pb push_back
#define eb emplace_back
template<class t,class u>bool chmax(t &a,u b){
	if(a <b){a=b;return true;}
	else return false;
}
template<class t,class u>bool chmin(t &a,u b){
	if(a>b){a=b;return true;}
	else return false;
}

#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())

template<class t>void mkuni(vc<t>&vs){
	sort(all(vs));
	vs.erase(unique(all(vs)),vs.ed);
}
template<class t>int lwb(const vc<t>&vs,t a){
	return lower_bound(all(vs),a)-vs.bg;
}

bool inc(int a,int b,int c){return a<=b&&b<=c;}

const int inf=INT_MAX/2-100;

using pi=pair<int,int>;

int getid(int h,int w){
	if(h<w)swap(h,w);
	return h*(h-1)/2+w-1;
}

const int smax=6;
const int S=smax*(smax+1)/2;

vc<pi> ls[S];

int readid(){
	string s;cin>>s;
	int res=getid(s[0]-'0',s[2]-'0');
	return res;
}

using T=tuple<int,ull,int>;
void reduce(vc<T>&vs){
	sort(all(vs));
	int s=0;
	for(auto [bit,cnt,val]:vs){
		if(s==0||get<0>(vs[s-1])!=bit||get<1>(vs[s-1])!=cnt)
			vs[s++]=T(bit,cnt,val);
	}
	vs.resize(s);
}

ull mask(int i){
	return (ull(1)<<i)-1;
}

const int cmax=6;
void increment(ull&v,int i){
	int cur=(v>>(i*3))&7;
	int nx=min(cur+1,cmax);
	int dif=cur^nx;
	v^=ull(dif)<<(i*3);
}

void slv(){
	rng(h,1,smax+1)rng(w,1,h+1){
		int idx=getid(h,w);
		//vert
		rng(i,1,h){
			int x=getid(i,w);
			int y=getid(h-i,w);
			ls[idx].pb(minmax(x,y));
		}
		//hori
		rng(i,1,w){
			int x=getid(h,i);
			int y=getid(h,w-i);
			ls[idx].pb(minmax(x,y));
		}
		mkuni(ls[idx]);
	}
	
	int n,t;cin>>n>>t;
	vi rw(S);
	rep(i,n)rw[readid()]++;
	vc<bool> ok(1<<S);
	{
		vi f(S);
		rng(h,1,smax+1)rng(w,1,h+1)f[getid(h,w)]=h*w;
		int tot=0;
		rep(i,S)tot+=f[i]*rw[i];
		int cur=0;
		rep(bit,1<<S){
			if(tot-cur>=2*t)ok[bit]=true;
			rep(i,S)if(bit&1<<i){
				cur-=f[i];
			}else{
				cur+=f[i];
				break;
			}
		}
	}
	vi easy(1<<S,inf);
	rep(bit,1<<S){
		if(ok[bit])easy[bit]=0;
		else{
			rep(i,S)if(rw[i]>0||(bit&1<<i)){
				for(auto [x,y]:ls[i]){
					chmin(easy[bit],easy[bit^1<<i^1<<x^1<<y]+1);
				}
			}
		}
	}
	
	int ans=inf;
	
	int inibit=0;
	ull inicnt=0;
	rep(i,S){
		inicnt+=ull(min(rw[i],cmax))<<(i*3);
		if(rw[i]%2)inibit+=1<<i;
	}
	
	vc<T> dp[2][cmax+1];
	auto push=[&](int tar,int i,int bit,ull cnt,int val){
		if(ok[bit]){
			chmin(ans,val);
			return;
		}
		chmin(ans,val+easy[bit]);
		if(i==-1||val+1>=ans||!ok[bit>>(i+1)<<(i+1)])return;
		dp[tar][(cnt>>(i*3))&7].eb(bit,cnt&mask(i*3),val);
	};
	auto push2=[&](int tar,int i,int c,int bit,ull cnt,int val){
		if(ok[bit]){
			chmin(ans,val);
			return;
		}
		chmin(ans,val+easy[bit]);
		if(i==-1||val+1>=ans||!ok[bit>>(i+1)<<(i+1)])return;
		dp[tar][c].eb(bit,cnt&mask(i*3),val);
	};
	int cur=0;
	push(cur,S-1,inibit,inicnt,0);
	per(i,S){
		int nx=cur^1;
		rep(c,cmax+1)dp[nx][c].clear();
		per(c,cmax+1){
			reduce(dp[cur][c]);
			for(auto [bit,cnt,val]:dp[cur][c]){
				assert(cnt<(ull(1)<<(i*3)));
			}
			if(i>0){
				for(auto [bit,cnt,val]:dp[cur][c]){
					assert(!ok[bit]);
					push(nx,i-1,bit,cnt,val);
				}
			}
			if(c>0){
				for(auto [bit,cnt,val]:dp[cur][c]){
					for(auto [x,y]:ls[i]){
						int nxbit=bit^1<<i^1<<x^1<<y;
						ull nxcnt=cnt;
						increment(nxcnt,x);
						increment(nxcnt,y);
						push2(cur,i,c-1,nxbit,nxcnt,val+1);
					}
				}
			}
		}
		cur=nx;
	}
	
	cout<<ans<<endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	slv();
}

详细

Test #1:

score: 100
Accepted
time: 254ms
memory: 11676kb

input:

16 118
5x6 3x5 4x5 6x3 6x1 1x1 4x5 4x5 2x3 1x2 5x3 5x3 6x2 3x6 5x6 4x2

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 239ms
memory: 11572kb

input:

6 30
2x3 3x3 1x5 2x5 3x5 3x5

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 282ms
memory: 11644kb

input:

3 2
1x1 1x1 1x2

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 234ms
memory: 11648kb

input:

4 25
2x3 3x3 2x5 5x5

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 251ms
memory: 11568kb

input:

5 10
1x1 1x1 1x1 1x1 4x4

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 220ms
memory: 11640kb

input:

6 34
1x1 1x2 2x3 3x3 5x5 5x5

output:

2

result:

ok single line: '2'

Test #7:

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

input:

15 70
1x1 1x2 1x3 1x4 1x5 2x2 2x3 2x4 2x5 3x3 3x4 3x5 4x4 4x5 5x5

output:

7

result:

ok single line: '7'

Test #8:

score: 0
Accepted
time: 206ms
memory: 11488kb

input:

11 40
1x1 1x2 1x3 2x3 2x4 4x5 2x2 2x2 1x4 2x4 4x5

output:

3

result:

ok single line: '3'

Test #9:

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

input:

20 74
4x3 5x1 4x2 3x3 1x2 2x1 4x2 1x5 1x1 1x4 1x1 5x5 1x4 4x5 3x2 3x5 1x2 3x4 1x1 2x3

output:

6

result:

ok single line: '6'

Test #10:

score: 0
Accepted
time: 224ms
memory: 11508kb

input:

20 104
4x2 2x3 4x5 5x1 1x3 4x3 1x2 1x1 5x2 5x4 5x5 4x1 5x5 3x5 4x2 3x1 3x1 5x4 2x1 4x4

output:

6

result:

ok single line: '6'

Test #11:

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

input:

13 44
5x4 3x2 3x2 4x1 4x4 1x2 1x5 1x2 1x1 3x5 1x2 1x3 3x2

output:

5

result:

ok single line: '5'

Test #12:

score: 0
Accepted
time: 230ms
memory: 11664kb

input:

5 21
1x3 1x2 5x4 4x4 1x1

output:

3

result:

ok single line: '3'

Test #13:

score: 0
Accepted
time: 213ms
memory: 11556kb

input:

18 77
5x4 4x2 5x5 1x4 3x1 4x3 2x3 1x1 3x4 5x2 5x3 2x2 2x1 2x1 1x2 5x3 3x3 1x4

output:

6

result:

ok single line: '6'

Test #14:

score: 0
Accepted
time: 225ms
memory: 11648kb

input:

9 30
5x2 5x3 1x4 1x4 2x3 1x2 3x3 2x3 4x1

output:

5

result:

ok single line: '5'

Test #15:

score: 0
Accepted
time: 220ms
memory: 11488kb

input:

8 37
2x4 1x3 5x4 5x5 2x4 1x4 1x2 1x4

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 216ms
memory: 11940kb

input:

19 103
1x5 5x2 2x2 5x4 1x5 1x1 5x5 2x2 2x5 5x4 3x4 3x2 4x4 5x4 5x3 2x2 2x4 4x3 3x3

output:

7

result:

ok single line: '7'

Test #17:

score: 0
Accepted
time: 211ms
memory: 11556kb

input:

19 75
2x1 1x1 5x5 2x4 1x3 2x3 2x2 2x3 4x5 4x3 3x1 4x1 4x2 4x4 5x1 1x4 1x5 5x3 3x1

output:

7

result:

ok single line: '7'

Test #18:

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

input:

20 81
2x3 2x5 5x3 2x1 3x1 5x2 4x5 2x1 1x5 5x2 2x5 1x5 3x2 1x5 1x2 4x2 4x2 5x4 3x2 3x3

output:

2

result:

ok single line: '2'

Test #19:

score: 0
Accepted
time: 269ms
memory: 13944kb

input:

47 297
3x5 3x2 1x5 5x6 5x5 5x5 4x2 5x4 4x1 6x2 6x6 5x3 1x2 2x6 6x2 3x3 2x2 2x2 1x4 2x5 5x3 4x4 6x3 3x6 5x4 3x6 3x1 6x1 3x1 1x2 3x4 1x6 6x6 5x3 1x1 5x5 2x1 1x4 5x1 5x6 2x1 4x6 2x2 6x6 2x3 6x1 3x1

output:

9

result:

ok single line: '9'

Test #20:

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

input:

33 197
1x5 2x1 3x6 2x1 5x5 1x4 2x2 2x6 2x4 6x3 2x1 1x3 6x5 6x1 3x2 3x3 4x3 4x6 6x6 6x1 5x2 5x2 1x6 4x4 6x2 2x1 6x5 1x5 2x1 5x6 2x3 3x6 3x5

output:

9

result:

ok single line: '9'

Test #21:

score: 0
Accepted
time: 277ms
memory: 11556kb

input:

29 458
5x6 6x6 6x6 5x6 6x6 5x6 6x6 6x5 6x5 6x6 6x5 6x6 6x5 6x6 6x6 6x6 6x5 5x6 5x5 6x6 6x5 5x5 5x5 6x5 5x6 6x6 6x5 5x5 6x5

output:

1

result:

ok single line: '1'

Test #22:

score: 0
Accepted
time: 219ms
memory: 11520kb

input:

29 142
1x1 5x1 3x5 1x3 5x2 2x4 1x4 1x4 5x5 4x2 1x2 5x1 5x2 2x1 5x3 2x5 4x3 3x2 4x4 2x1 1x4 6x6 1x5 5x4 2x4 3x4 4x4 5x3 1x5

output:

5

result:

ok single line: '5'

Test #23:

score: 0
Accepted
time: 253ms
memory: 12212kb

input:

29 187
6x1 5x4 4x3 6x3 2x3 2x3 1x3 6x2 4x4 5x6 6x4 3x5 5x1 6x5 5x2 5x3 5x6 5x6 1x3 2x5 3x5 2x1 2x5 1x5 1x4 3x1 4x2 2x3 4x5

output:

7

result:

ok single line: '7'

Test #24:

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

input:

30 180
3x6 1x2 2x5 1x1 1x1 6x3 3x3 4x1 2x3 2x6 3x5 3x6 4x1 3x3 6x5 4x2 6x4 5x4 6x6 3x2 4x4 1x5 4x3 4x4 2x4 3x4 2x5 1x6 3x3 5x3

output:

8

result:

ok single line: '8'

Test #25:

score: 0
Accepted
time: 243ms
memory: 11516kb

input:

23 151
3x6 5x3 1x1 2x5 1x5 6x5 4x4 3x4 2x3 3x1 1x1 6x6 2x3 6x6 2x6 2x2 3x3 3x2 6x4 3x4 2x1 4x5 6x3

output:

5

result:

ok single line: '5'

Test #26:

score: 0
Accepted
time: 251ms
memory: 12992kb

input:

21 149
1x4 4x6 5x5 4x6 4x1 5x3 6x2 4x4 3x5 6x3 2x4 3x3 6x6 3x2 1x2 5x3 6x5 6x4 1x1 2x2 6x1

output:

9

result:

ok single line: '9'

Test #27:

score: 0
Accepted
time: 254ms
memory: 12700kb

input:

50 330
4x2 5x4 6x2 4x4 2x3 6x6 5x3 5x6 3x3 5x1 5x2 4x3 1x3 5x4 2x6 1x6 3x6 6x4 6x6 1x6 4x6 1x3 4x5 6x6 1x1 1x1 3x4 3x5 1x1 2x4 1x3 2x1 3x5 1x5 2x4 1x5 6x4 3x6 2x6 1x5 1x6 6x6 1x3 6x1 5x6 6x6 3x2 1x5 6x1 2x2

output:

8

result:

ok single line: '8'

Test #28:

score: 0
Accepted
time: 249ms
memory: 12188kb

input:

39 250
5x6 6x4 1x1 3x1 6x1 5x3 2x6 4x4 6x1 1x4 6x6 4x5 3x6 4x2 5x6 4x3 2x4 5x1 6x3 5x6 3x5 4x5 6x5 2x2 5x1 6x6 3x3 5x3 4x1 6x4 2x2 1x5 2x2 2x1 2x1 1x2 1x3 2x5 4x1

output:

7

result:

ok single line: '7'

Test #29:

score: 0
Accepted
time: 264ms
memory: 11648kb

input:

50 889
5x5 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 5x5 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6

output:

0

result:

ok single line: '0'

Test #30:

score: 0
Accepted
time: 239ms
memory: 11680kb

input:

4 31
2x2 2x5 4x3 6x6

output:

4

result:

ok single line: '4'

Test #31:

score: 0
Accepted
time: 221ms
memory: 11908kb

input:

14 85
1x1 6x5 1x6 4x6 5x6 1x5 5x5 4x3 4x3 1x3 3x3 1x4 2x4 1x1

output:

4

result:

ok single line: '4'

Test #32:

score: 0
Accepted
time: 261ms
memory: 11576kb

input:

27 174
6x2 6x1 3x5 3x3 1x4 5x6 5x4 3x2 3x1 1x6 4x4 6x5 4x1 4x4 3x6 2x4 4x6 6x6 6x6 5x2 4x2 1x6 1x2 1x3 1x2 3x4 1x6

output:

5

result:

ok single line: '5'

Test #33:

score: 0
Accepted
time: 235ms
memory: 11644kb

input:

25 138
4x6 3x4 1x3 4x4 3x1 3x4 5x2 1x1 5x3 1x6 6x4 6x3 2x1 5x2 1x6 1x6 4x2 4x6 6x2 4x6 3x1 5x1 6x2 1x5 3x5

output:

3

result:

ok single line: '3'

Test #34:

score: 0
Accepted
time: 250ms
memory: 11788kb

input:

50 269
2x6 4x3 2x4 2x4 3x1 2x1 5x6 2x6 3x6 6x1 3x3 4x6 1x6 2x5 6x6 1x2 2x3 1x5 5x3 5x6 3x1 2x3 3x4 6x3 4x2 3x2 4x3 3x6 1x2 2x2 2x3 3x4 2x6 1x5 2x4 5x3 6x3 6x4 1x2 1x6 1x5 1x5 1x4 6x5 4x3 3x4 2x5 1x3 3x1 1x3

output:

4

result:

ok single line: '4'

Test #35:

score: 0
Accepted
time: 252ms
memory: 11624kb

input:

46 260
6x5 1x6 2x4 5x1 5x6 4x4 1x4 5x3 2x6 3x2 1x5 1x2 3x2 4x3 5x1 5x1 6x2 1x6 6x2 5x6 2x2 3x1 4x2 4x1 5x6 1x6 6x1 6x4 4x4 6x1 3x4 2x2 3x1 2x6 2x3 2x3 3x1 2x1 5x4 6x5 3x6 6x5 3x4 6x2 2x5 6x1

output:

4

result:

ok single line: '4'

Test #36:

score: 0
Accepted
time: 244ms
memory: 11644kb

input:

41 194
2x1 1x5 3x1 2x1 6x5 1x5 5x3 6x1 5x2 1x5 1x5 6x3 2x1 1x2 3x2 3x6 6x5 5x2 4x5 2x4 6x1 5x1 3x1 2x3 5x3 5x5 1x2 4x2 4x2 2x2 5x3 1x3 5x3 4x6 3x2 4x1 6x3 3x3 4x1 4x1 1x2

output:

5

result:

ok single line: '5'

Test #37:

score: 0
Accepted
time: 250ms
memory: 11516kb

input:

43 242
6x3 3x5 1x2 5x4 2x6 1x6 2x4 1x6 3x2 2x5 2x1 3x1 4x1 3x5 6x3 3x6 6x4 1x2 2x1 2x3 6x3 4x6 5x4 5x3 3x5 1x5 1x3 1x1 4x4 2x2 4x6 1x2 2x2 2x5 3x2 5x6 2x3 6x3 5x5 1x4 6x5 2x2 1x3

output:

5

result:

ok single line: '5'

Test #38:

score: 0
Accepted
time: 247ms
memory: 11640kb

input:

5 29
1x5 2x5 3x3 2x3 6x5

output:

3

result:

ok single line: '3'

Test #39:

score: 0
Accepted
time: 14ms
memory: 11860kb

input:

49 230
3x3 4x3 4x6 3x6 4x6 2x3 5x6 1x3 6x6 5x1 1x2 6x6 1x1 1x4 6x6 3x3 2x3 1x2 4x4 5x2 6x3 5x5 1x4 1x4 1x1 6x3 4x6 5x1 6x5 5x6 1x6 1x6 1x3 3x3 2x1 6x1 4x5 4x2 6x6 3x1 4x5 2x2 3x4 4x5 3x2 6x1 2x3 6x6 3x6

output:

0

result:

ok single line: '0'

Test #40:

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

input:

45 304
2x4 2x5 6x6 1x5 3x3 2x5 1x6 4x1 5x5 2x2 5x3 5x1 6x6 5x4 6x5 6x5 1x5 2x3 6x4 4x3 1x2 6x1 1x5 6x2 1x5 5x2 4x3 6x1 4x5 2x5 6x4 2x6 5x5 6x5 3x1 5x6 3x3 3x2 4x4 6x3 6x4 1x6 3x3 4x6 1x6

output:

4

result:

ok single line: '4'

Test #41:

score: 0
Accepted
time: 264ms
memory: 11844kb

input:

44 278
2x3 6x2 6x6 6x1 3x3 3x5 1x6 3x3 1x4 5x2 3x3 3x4 2x5 6x3 2x5 2x6 5x1 6x2 5x6 5x6 4x2 6x1 1x6 1x2 1x1 1x1 4x6 4x3 4x3 6x3 2x1 1x6 5x3 4x3 6x4 5x6 4x1 5x6 4x4 3x4 6x6 4x1 5x2 5x6

output:

4

result:

ok single line: '4'

Test #42:

score: 0
Accepted
time: 275ms
memory: 11756kb

input:

48 261
4x4 1x2 2x4 6x3 3x3 6x5 5x1 5x3 1x3 5x6 1x5 4x6 6x4 3x5 6x5 5x3 2x5 4x5 3x6 2x5 2x2 2x6 4x2 2x6 2x6 6x5 6x4 5x1 3x3 4x2 2x6 6x2 4x4 4x4 3x3 4x1 1x5 1x5 4x1 1x4 4x2 2x2 1x3 5x3 3x4 2x4 5x4 3x5

output:

1

result:

ok single line: '1'

Test #43:

score: 0
Accepted
time: 251ms
memory: 11876kb

input:

40 260
3x5 5x6 1x5 6x4 2x2 1x2 5x1 3x5 2x4 1x6 3x6 6x5 4x2 6x5 4x5 1x5 5x3 6x4 4x5 2x2 4x1 2x4 2x4 6x1 5x6 6x6 6x3 6x6 6x1 4x2 5x5 3x2 3x3 4x6 2x2 4x2 6x4 4x3 4x2 3x1

output:

2

result:

ok single line: '2'

Test #44:

score: 0
Accepted
time: 342ms
memory: 11840kb

input:

1 1
1x3

output:

2

result:

ok single line: '2'

Test #45:

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

input:

49 324
4x3 1x6 1x5 1x5 5x4 4x5 6x5 1x2 5x6 4x1 2x2 4x6 6x5 5x5 4x2 5x2 4x6 1x5 5x3 1x6 5x1 3x5 5x1 6x4 6x3 2x3 1x2 4x6 5x5 1x5 1x6 2x4 6x1 3x3 4x4 3x4 5x4 6x1 5x6 4x6 6x1 4x2 1x6 3x5 5x1 1x2 2x4 6x6 3x4

output:

8

result:

ok single line: '8'

Test #46:

score: 0
Accepted
time: 265ms
memory: 11764kb

input:

40 222
1x3 4x1 3x3 1x3 4x5 3x2 1x3 2x2 3x6 5x2 2x3 1x3 2x1 6x3 1x4 5x4 2x5 4x2 1x4 1x2 5x4 1x4 6x4 5x2 6x6 4x4 1x1 6x1 5x3 4x2 6x5 6x3 3x5 4x5 1x5 3x4 6x2 5x4 3x5 4x3

output:

6

result:

ok single line: '6'

Test #47:

score: 0
Accepted
time: 265ms
memory: 11788kb

input:

43 229
2x4 5x1 5x2 1x4 4x4 6x3 3x1 6x4 3x1 5x1 4x4 3x1 2x5 5x3 2x3 4x4 6x4 3x1 4x6 3x4 1x2 4x5 2x3 3x5 4x1 2x3 3x3 1x3 1x6 2x6 1x6 2x3 5x5 5x2 6x6 5x1 4x3 2x5 4x1 1x5 5x6 6x1 5x3

output:

5

result:

ok single line: '5'

Test #48:

score: 0
Accepted
time: 258ms
memory: 11768kb

input:

46 295
6x1 2x6 4x3 3x5 4x2 4x4 1x5 6x1 5x6 3x5 5x6 5x5 4x5 4x2 5x2 3x2 5x1 1x1 5x1 5x4 5x1 6x5 4x1 6x6 5x5 1x6 3x3 3x5 1x3 2x2 5x6 3x2 5x1 4x1 3x3 6x6 3x5 6x4 2x1 3x1 5x1 2x2 3x1 2x6 5x5 3x5

output:

6

result:

ok single line: '6'

Test #49:

score: 0
Accepted
time: 256ms
memory: 11872kb

input:

50 318
3x2 6x5 6x2 4x5 3x3 1x2 6x4 4x4 2x1 1x5 1x6 5x4 4x3 3x6 2x4 5x5 4x4 6x6 2x1 3x4 1x5 3x6 6x1 4x1 1x1 6x2 4x6 5x5 2x3 2x1 4x6 2x1 4x2 3x3 4x4 6x6 1x2 2x4 4x3 4x1 3x5 6x2 4x2 5x6 2x4 3x3 2x1 1x2 3x5 5x6

output:

6

result:

ok single line: '6'

Test #50:

score: 0
Accepted
time: 286ms
memory: 11768kb

input:

30 294
5x5 5x5 2x6 4x4 2x6 2x5 6x5 6x5 6x5 6x3 5x4 6x5 4x4 6x2 4x6 6x5 5x6 6x4 2x6 4x4 5x6 5x6 4x6 6x6 6x6 1x5 4x6 3x5 6x6 4x4

output:

1

result:

ok single line: '1'

Test #51:

score: 0
Accepted
time: 261ms
memory: 11764kb

input:

37 305
3x3 4x2 3x6 3x6 4x4 4x5 5x3 3x6 6x5 3x6 4x5 6x1 3x5 4x6 4x4 4x2 4x6 3x5 6x4 4x4 6x6 6x6 6x4 4x4 2x6 5x5 5x4 6x5 4x5 3x5 6x2 5x5 6x4 5x4 6x1 3x6 3x6

output:

0

result:

ok single line: '0'

Test #52:

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

input:

50 459
4x6 1x6 2x6 3x4 4x1 4x5 6x4 4x6 4x6 2x6 4x5 3x4 2x4 6x6 5x5 5x6 6x3 2x6 5x4 2x6 5x3 4x6 6x5 4x6 5x3 2x5 6x4 6x2 5x2 6x6 6x2 6x6 5x5 1x6 5x1 5x4 5x6 3x6 2x3 5x6 6x1 3x5 5x2 6x5 3x6 5x6 3x3 4x1 6x5 4x6

output:

7

result:

ok single line: '7'

Test #53:

score: 0
Accepted
time: 102ms
memory: 11772kb

input:

50 453
4x6 6x3 6x5 4x3 5x5 6x6 6x5 2x6 3x5 5x5 6x3 4x5 5x5 3x4 4x2 4x5 5x6 4x5 6x5 5x6 5x2 6x6 6x6 6x1 3x4 5x2 5x3 5x6 4x5 6x6 3x6 3x1 6x6 6x5 3x4 5x2 2x6 6x2 6x6 6x4 5x4 6x5 5x4 4x5 5x3 1x6 5x5 6x5 6x5 5x3

output:

0

result:

ok single line: '0'

Test #54:

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

input:

50 452
5x6 6x6 2x5 4x5 5x4 2x5 5x6 5x4 3x5 6x5 2x5 5x6 5x6 6x6 5x3 3x3 5x5 5x6 5x5 3x6 4x6 6x3 5x4 6x6 6x2 1x6 6x3 5x6 4x4 5x2 6x6 5x6 3x5 3x5 2x5 5x5 6x6 3x5 5x5 5x4 6x6 2x1 4x5 6x3 5x6 5x3 5x6 2x4 6x3 5x6

output:

0

result:

ok single line: '0'

Test #55:

score: 0
Accepted
time: 263ms
memory: 11680kb

input:

50 900
6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6

output:

0

result:

ok single line: '0'

Test #56:

score: 0
Accepted
time: 260ms
memory: 11876kb

input:

50 894
6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 6x6 5x5

output:

3

result:

ok single line: '3'

Test #57:

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

input:

47 399
4x5 6x6 6x1 6x6 6x2 3x4 4x3 6x6 6x4 5x5 6x3 2x4 4x1 5x6 3x5 6x6 6x3 5x4 5x6 2x4 6x4 2x1 3x4 5x5 5x3 3x4 5x5 5x5 6x3 4x6 3x3 6x6 6x6 2x4 5x4 2x6 5x6 2x6 2x1 4x6 1x6 5x6 1x4 6x4 6x4 3x5 6x6

output:

0

result:

ok single line: '0'