QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#111768#6398. Puzzle: Tapado_while_true#AC ✓5ms9908kbC++144.5kb2023-06-08 17:19:552023-06-08 17:19:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-08 17:19:59]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:9908kb
  • [2023-06-08 17:19:55]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pil>vpil;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
	int s=1;
	while(y){
		if(y&1)s=1ll*s*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return s;
}
const int N=2000010;
const int inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
int ent=1,S,T,tot;
int head[N],cur[N],dis[N]; 
struct Edge{
	int nxt,to;
	ll fl;
}e[N<<1];
inline void addedge(int x,int y,int w){
	e[++ent]={head[x],y,w};head[x]=ent;
	e[++ent]={head[y],x,0};head[y]=ent;
}
bool bfs(){
	for(int i=1;i<=tot;i++)cur[i]=head[i],dis[i]=inf;
	dis[S]=0;queue<int>q;q.push(S);
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=head[x];i;i=e[i].nxt){
			int v=e[i].to;ll w=e[i].fl;
			if(w){
				if(dis[v]>dis[x]+1){
					dis[v]=dis[x]+1;
					q.push(v);
				}
			}
		}
	}
	return dis[T]!=inf;
}
ll dfs(int x,ll flow){
	if(x==T)return flow;
	ll fl=0;
	for(int i=cur[x];i&&fl<flow;i=e[i].nxt){
		cur[x]=i;
		int v=e[i].to;ll w=e[i].fl;
		if(w && dis[v]==dis[x]+1){
			ll of=dfs(v,min(w,flow-fl));
			fl+=of;e[i].fl-=of;e[i^1].fl+=of;
		}
	}
	return fl;
}
ll dinic(){
	ll s=0;
	while(bfs())
		s+=dfs(S,INF);
	return s;
}
int n,m;
char s[210][210];
int a[210][210],p[210][210];
signed main(){
	#ifdef do_while_true
//		assert(freopen("data.in","r",stdin));
//		assert(freopen("data.out","w",stdout));
	#endif
	read(n);read(m);
	n=2*n-1,m=2*m-1; 
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
	S=++tot;T=++tot;
	int rct=0;
	for(int i=1;i<=n;i+=2){
		for(int j=1;j<=m;j+=2){
			int t=8;
			if((i==1||i==n)&&(j==1||j==m))t=3;
			else if((i==1||i==n)||(j==1||j==m))t=5;
			a[i][j]=((s[i][j]-'0')!=t);
			if(a[i][j]){
//				dpi(i/2+1,j/2+1);
				++rct;
				p[i][j]=++tot;
				if((i/2+j/2)&1)addedge(S,p[i][j],1);
				else addedge(p[i][j],T,1);
			}
		}
	}
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<=m;j+=2)if(a[i][j] && ((i/2+j/2)&1)){
//			dpi(i,j);
			if(i<n && a[i+2][j] && !(j>1&&j<m&&(i==n-2||i==1)))addedge(p[i][j],p[i+2][j],1);
			if(i>1 && a[i-2][j] && !(j>1&&j<m&&(i==3||i==n)))addedge(p[i][j],p[i-2][j],1);
			if(j<m && a[i][j+2] && !(i>1&&i<n&&(j==m-2||j==1)))addedge(p[i][j],p[i][j+2],1);
			if(j>1 && a[i][j-2] && !(i>1&&i<n&&(j==3||j==m)))addedge(p[i][j],p[i][j-2],1);
		}
	int flow=dinic();
	if(flow*2==rct){
		puts("YES");
		int ct=1;
		for(int i=1;i<=n;i+=2)
			for(int j=1;j<=m;j+=2)
				if(a[i][j])
					ct+=2;
		for(int i=1;i<=n;i+=2)
			for(int j=1;j<=m;j+=2)if(a[i][j] && ((i/2+j/2)&1)){
				if(i<n && a[i+2][j] && !(j>1&&j<m&&(i==n-2||i==1))){
					if(!e[ct+1].fl)
						s[i+1][j]='#';
					ct+=2;
				}
				if(i>1 && a[i-2][j] && !(j>1&&j<m&&(i==3||i==n))){
					if(!e[ct+1].fl)
						s[i-1][j]='#';
					ct+=2;
				}
				if(j<m && a[i][j+2] && !(i>1&&i<n&&(j==m-2||j==1))){
					if(!e[ct+1].fl)
						s[i][j+1]='#';
					ct+=2;
				}
				if(j>1 && a[i][j-2] && !(i>1&&i<n&&(j==3||j==m))){
					if(!e[ct+1].fl)
						s[i][j-1]='#';
					ct+=2;
				}
			}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
				if(s[i][j]=='.')s[i][j]='#';
				else if(s[i][j]=='#')s[i][j]='.';
			printf("%s\n",s[i]+1);
		}
	}
	else puts("NO");
    #ifdef do_while_true
		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 9736kb

input:

3 3
2.4.3
.....
5.8.5
.....
3.5.3

output:

YES
2.4#3
#####
5#8#5
#####
3#5#3

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 1ms
memory: 7572kb

input:

3 3
3.4.3
.....
5.7.5
.....
3.5.3

output:

NO

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 2ms
memory: 9620kb

input:

2 2
2.2
...
2.2

output:

YES
2.2
###
2.2

result:

ok Correct.

Test #4:

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

input:

2 50
2.4.4.4.4.5.5.5.5.5.5.5.5.4.5.5.4.4.5.5.5.5.4.5.5.5.5.5.4.4.5.4.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.5.3
...................................................................................................
2.5.5.4.4.5.5.5.4.4.5.5.5.4.5.5.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.5.4.4.5.5.5.5.4...

output:

NO

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 2ms
memory: 7604kb

input:

2 50
2.4.4.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.4.4.5.5.5.4.5.4.4.4.5.4.4.5.4.4.5.5.5.5.4.4.5.5.5.5.5.2
...................................................................................................
3.5.4.5.5.5.5.5.5.5.5.5.5.5.4.5.5.5.5.4.5.5.5.5.4.4.5.4.5.4.5.5.5.5.5.4.4.5.5.5.4.4.5.5.5.5.5.4...

output:

NO

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 2ms
memory: 7764kb

input:

50 2
3.2
...
5.4
...
5.5
...
4.4
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.4
...
5.4
...
4.4
...
5.5
...
5.5
...
4.4
...
5.4
...
5.4
...
5.5
...
4.5
...
4.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
......

output:

NO

result:

ok Correct.

Test #7:

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

input:

50 2
3.3
...
5.4
...
5.4
...
5.4
...
5.4
...
5.5
...
4.4
...
4.4
...
5.5
...
4.4
...
5.5
...
5.5
...
5.5
...
5.5
...
4.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.4
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
4.5
...
4.5
...
4.5
...
4.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
4.4
...
4.4
......

output:

NO

result:

ok Correct.

Test #8:

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

input:

3 50
3.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.5.5.5.5.5.5.4.4.5.5.4.4.5.4.4.5.3
...................................................................................................
4.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.7.7.7.7.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.8...

output:

YES
3#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#4.4#5#5#5#5#4.4#5#5#5#5#5#5#5#5#4.4#5#5#4.4#5#4.4#5#3
###################################################################################################
4#8#8#8#8#8#8#8#8#8#8#8#8#8#8#7.7#7.7#7.7#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#7.7#8#...

result:

ok Correct.

Test #9:

score: 0
Accepted
time: 2ms
memory: 7692kb

input:

3 50
2.4.4.4.5.4.4.4.4.4.4.5.5.4.4.5.5.4.4.5.5.5.4.4.5.5.5.4.4.5.5.4.4.4.4.5.5.5.5.5.5.4.4.5.5.5.5.4.4.3
...................................................................................................
5.7.7.8.7.7.7.7.8.8.8.8.7.7.8.7.7.8.8.8.8.7.7.8.8.8.7.7.8.7.7.8.8.8.8.7.7.8.8.7.7.8.8.8.7.7.8.8...

output:

YES
2.4#4.4#5#4.4#4.4#4.4#5#5#4.4#5#5#4.4#5#5#5#4.4#5#5#5#4.4#5#5#4.4#4.4#5#5#5#5#5#5#4.4#5#5#5#5#4.4#3
###################################################################################################
5#7.7#8#7.7#7.7#8#8#8#8#7.7#8#7.7#8#8#8#8#7.7#8#8#8#7.7#8#7.7#8#8#8#8#7.7#8#8#7.7#8#8#8#7.7#8#8#...

result:

ok Correct.

Test #10:

score: 0
Accepted
time: 0ms
memory: 9696kb

input:

50 3
3.5.3
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
5.8.4
.....
5.8.4
.....
4.8.5
.....
4.7.5
.....
5.7.5
.....
5.8.5
.....
5.8.4
.....
5.8.4
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
4.8.5
.....
4.7.5
.....
5.7.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
....

output:

YES
3#5#3
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
5#8#4
####.
5#8#4
#####
4#8#5
.####
4#7#5
##.##
5#7#5
#####
5#8#5
#####
5#8#4
####.
5#8#4
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
4#8#5
.####
4#7#5
##.##
5#7#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
##...

result:

ok Correct.

Test #11:

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

input:

50 3
2.4.3
.....
4.8.5
.....
4.8.5
.....
5.8.5
.....
4.7.4
.....
4.7.4
.....
4.8.5
.....
4.8.4
.....
5.8.4
.....
4.7.5
.....
4.7.5
.....
5.8.5
.....
5.8.5
.....
5.8.4
.....
5.8.4
.....
5.8.5
.....
5.8.5
.....
5.7.5
.....
5.7.5
.....
5.8.5
.....
5.8.5
.....
5.8.5
.....
4.8.5
.....
4.7.5
.....
4.7.4
....

output:

YES
2.4#3
#####
4#8#5
.####
4#8#5
#####
5#8#5
#####
4#7#4
.#.#.
4#7#4
#####
4#8#5
.####
4#8#4
####.
5#8#4
#####
4#7#5
.#.##
4#7#5
#####
5#8#5
#####
5#8#5
#####
5#8#4
####.
5#8#4
#####
5#8#5
#####
5#8#5
#####
5#7#5
##.##
5#7#5
#####
5#8#5
#####
5#8#5
#####
5#8#5
#####
4#8#5
.####
4#7#5
##.##
4#7#4
.#...

result:

ok Correct.

Test #12:

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

input:

10 10
2.4.4.4.5.5.4.4.5.2
...................
5.7.8.8.7.8.7.7.8.4
...................
4.7.8.8.7.8.8.8.8.5
...................
4.8.8.8.7.7.8.8.8.4
...................
5.8.7.7.7.7.8.8.7.4
...................
4.7.7.8.8.8.8.8.7.4
...................
4.8.7.8.8.7.7.7.8.4
...................
5.8.7.8.8.7.8....

output:

YES
2.4#4.4#5#5#4.4#5#2
##################.
5#7#8#8#7#8#7.7#8#4
##.#####.##########
4#7#8#8#7#8#8#8#8#5
.##################
4#8#8#8#7.7#8#8#8#4
##################.
5#8#7.7#7.7#8#8#7#4
################.##
4#7.7#8#8#8#8#8#7#4
.#################.
4#8#7#8#8#7#7.7#8#4
####.#####.########
5#8#7#8#8#7#8#8#...

result:

ok Correct.

Test #13:

score: 0
Accepted
time: 0ms
memory: 9540kb

input:

10 10
3.5.5.5.5.5.5.4.4.3
...................
5.7.7.8.8.7.8.7.7.4
...................
5.8.8.7.7.7.7.7.8.4
...................
5.8.7.7.8.8.8.7.7.5
...................
5.8.8.7.7.7.7.7.7.5
...................
4.7.7.8.8.7.8.8.7.4
...................
4.7.7.7.7.7.7.8.7.4
...................
5.8.7.8.7.7.7....

output:

NO

result:

ok Correct.

Test #14:

score: 0
Accepted
time: 0ms
memory: 7620kb

input:

10 10
2.4.5.4.4.5.5.5.5.3
...................
4.8.7.7.8.8.8.7.8.4
...................
4.8.7.8.7.8.8.7.8.4
...................
5.7.7.8.7.7.7.8.7.5
...................
5.7.8.8.8.8.8.8.7.5
...................
4.7.8.7.7.7.8.8.8.5
...................
4.7.7.7.8.7.7.8.8.5
...................
4.7.8.7.8.8.7....

output:

YES
2.4#5#4.4#5#5#5#5#3
###################
4#8#7.7#8#8#8#7#8#4
.#############.###.
4#8#7#8#7#8#8#7#8#4
####.###.##########
5#7#7#8#7#7.7#8#7#5
##.#############.##
5#7#8#8#8#8#8#8#7#5
###################
4#7#8#7.7#7#8#8#8#5
.#.#######.########
4#7#7.7#8#7#7#8#8#5
############.######
4#7#8#7#8#8#7#8#...

result:

ok Correct.

Test #15:

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

input:

10 10
2.4.4.4.5.5.4.4.5.3
...................
5.7.8.8.7.7.7.7.7.5
...................
5.7.7.7.8.7.7.8.7.5
...................
4.8.7.7.8.8.8.7.8.4
...................
4.8.8.8.7.8.8.7.8.4
...................
4.8.8.8.7.8.8.8.8.5
...................
4.8.7.8.7.7.7.8.8.4
...................
5.8.7.8.7.8.8....

output:

YES
2.4#4.4#5#5#4.4#5#3
###################
5#7#8#8#7.7#7.7#7#5
##.#############.##
5#7#7.7#8#7.7#8#7#5
###################
4#8#7.7#8#8#8#7#8#4
.#############.###.
4#8#8#8#7#8#8#7#8#4
########.##########
4#8#8#8#7#8#8#8#8#5
.##################
4#8#7#8#7#7.7#8#8#4
####.###.#########.
5#8#7#8#7#8#8#8#...

result:

ok Correct.

Test #16:

score: 0
Accepted
time: 2ms
memory: 7612kb

input:

10 10
3.5.4.4.5.5.4.4.5.3
...................
5.7.8.8.7.8.8.8.8.5
...................
5.7.8.8.7.7.7.8.8.5
...................
5.8.7.7.8.8.7.8.8.5
...................
5.8.8.8.8.8.7.8.8.4
...................
5.7.7.8.8.7.8.7.8.4
...................
5.7.8.8.8.7.7.7.8.5
...................
5.7.8.8.8.8.7....

output:

YES
3#5#4.4#5#5#4.4#5#3
###################
5#7#8#8#7#8#8#8#8#5
##.#####.##########
5#7#8#8#7#7.7#8#8#5
###################
5#8#7.7#8#8#7#8#8#5
############.######
5#8#8#8#8#8#7#8#8#4
##################.
5#7.7#8#8#7#8#7#8#4
##########.###.####
5#7#8#8#8#7#7#7#8#5
##.#########.######
5#7#8#8#8#8#7#8#...

result:

ok Correct.

Test #17:

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

input:

10 10
3.5.5.4.4.5.5.4.4.3
...................
5.7.7.7.7.8.8.7.7.5
...................
5.8.7.7.8.8.8.8.8.5
...................
5.7.8.8.8.7.7.8.8.4
...................
5.7.7.7.8.7.7.8.7.4
...................
5.8.8.8.7.7.8.8.7.5
...................
4.7.7.8.8.8.7.7.8.5
...................
4.8.8.8.7.7.8....

output:

YES
3#5#5#4.4#5#5#4.4#3
###################
5#7.7#7.7#8#8#7.7#5
###################
5#8#7.7#8#8#8#8#8#5
###################
5#7#8#8#8#7.7#8#8#4
##.###############.
5#7#7.7#8#7.7#8#7#4
################.##
5#8#8#8#7.7#8#8#7#5
###################
4#7.7#8#8#8#7.7#8#5
.##################
4#8#8#8#7.7#8#7#...

result:

ok Correct.

Test #18:

score: 0
Accepted
time: 0ms
memory: 7676kb

input:

10 10
2.4.4.5.4.4.4.4.4.2
...................
4.8.7.8.8.7.8.8.8.4
...................
4.8.7.8.7.7.7.7.7.4
...................
4.7.7.8.7.8.7.7.7.4
...................
5.8.7.8.7.7.8.8.8.4
...................
4.8.7.8.7.7.7.7.7.5
...................
4.8.7.7.8.8.7.7.7.5
...................
4.7.7.8.8.7.8....

output:

YES
2#4.4#5#4.4#4.4#4.2
.##################
4#8#7#8#8#7#8#8#8#4
####.#####.#######.
4#8#7#8#7#7#7#7.7#4
.#######.###.######
4#7.7#8#7#8#7#7.7#4
##################.
5#8#7#8#7#7#8#8#8#4
####.###.#.########
4#8#7#8#7#7#7.7#7#5
.###############.##
4#8#7.7#8#8#7.7#7#5
###################
4#7.7#8#8#7#8#8#...

result:

ok Correct.

Test #19:

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

input:

10 10
2.4.4.4.4.4.4.4.4.2
...................
4.8.8.7.7.7.7.8.8.5
...................
4.7.8.7.8.8.7.8.7.4
...................
4.7.8.7.7.8.7.7.7.4
...................
4.8.7.8.7.7.7.7.8.4
...................
4.8.7.8.7.7.7.7.7.4
...................
4.7.8.7.8.7.7.7.7.4
...................
4.7.7.7.7.7.7....

output:

YES
2.4#4.4#4.4#4.4#4.2
###################
4#8#8#7.7#7.7#8#8#5
.##################
4#7#8#7#8#8#7#8#7#4
##.###.#####.###.#.
4#7#8#7#7#8#7#7#7#4
.#######.#####.####
4#8#7#8#7#7.7#7#8#4
####.#############.
4#8#7#8#7.7#7.7#7#4
.###############.##
4#7#8#7#8#7.7#7#7#4
##.###.#######.###.
4#7#7#7#7#7.7#7#...

result:

ok Correct.

Test #20:

score: 0
Accepted
time: 2ms
memory: 7844kb

input:

50 50
3.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.3
...................................................................................................
5.8.8.8.8.7.7.8.8.8.8.8.7.7.8.8.8.7.7.7.8.8.8.8.8.8.8.8.8.8.8.7.8.8.8.7.7.8.8.8.8.8.8.8.8.7.8....

output:

YES
3#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#4.4#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#3
###################################################################################################
5#8#8#8#8#7.7#8#8#8#8#8#7.7#8#8#8#7#7.7#8#8#8#8#8#8#8#8#8#8#8#7#8#8#8#7.7#8#8#8#8#8#8#8#8#7#8#7....

result:

ok Correct.

Test #21:

score: 0
Accepted
time: 4ms
memory: 9624kb

input:

50 50
3.5.5.5.4.4.5.5.5.5.5.5.5.5.5.5.5.5.4.4.5.4.4.4.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.3
...................................................................................................
4.8.8.8.8.8.8.7.7.8.8.8.8.8.8.8.8.8.7.7.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8....

output:

NO

result:

ok Correct.

Test #22:

score: 0
Accepted
time: 0ms
memory: 9700kb

input:

50 50
3.5.4.4.5.5.5.5.4.4.5.4.4.5.5.4.4.5.5.5.5.5.5.4.4.5.5.5.5.5.5.4.4.5.5.4.4.5.5.5.5.5.5.5.5.5.5.5.5.3
...................................................................................................
5.7.7.8.8.8.7.7.7.8.8.8.8.8.7.8.8.8.8.8.8.8.8.8.8.7.7.8.8.7.7.8.8.8.8.8.8.8.8.8.7.7.8.8.8.8.7....

output:

YES
3#5#4.4#5#5#5#5#4.4#5#4.4#5#5#4.4#5#5#5#5#5#5#4.4#5#5#5#5#5#5#4.4#5#5#4.4#5#5#5#5#5#5#5#5#5#5#5#5#3
###################################################################################################
5#7.7#8#8#8#7.7#7#8#8#8#8#8#7#8#8#8#8#8#8#8#8#8#8#7.7#8#8#7.7#8#8#8#8#8#8#8#8#8#7.7#8#8#8#8#7#8#...

result:

ok Correct.

Test #23:

score: 0
Accepted
time: 0ms
memory: 7812kb

input:

50 50
3.5.4.4.5.4.4.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.4.4.4.5.5.4.4.5.4.4.5.5.5.4.5.5.5.4.4.5.5.4.4.5.5.5.4.2
...................................................................................................
4.7.8.8.8.7.7.8.7.7.8.8.7.8.8.8.8.7.7.8.8.8.8.8.7.8.8.8.8.8.8.8.8.8.8.8.8.8.7.8.8.8.8.8.7.8.8....

output:

NO

result:

ok Correct.

Test #24:

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

input:

50 50
2.4.5.4.4.5.4.4.5.5.5.4.4.4.4.5.5.5.5.4.4.5.5.5.4.4.5.4.4.5.4.4.5.4.4.5.4.4.5.4.4.5.4.4.5.5.5.5.5.3
...................................................................................................
5.8.8.8.8.7.8.8.8.8.8.8.8.8.7.7.8.8.8.8.8.8.7.7.7.8.8.8.8.7.7.8.8.8.7.8.8.8.7.7.8.8.8.8.7.7.8....

output:

YES
2.4#5#4.4#5#4.4#5#5#5#4.4#4.4#5#5#5#5#4.4#5#5#5#4.4#5#4.4#5#4.4#5#4.4#5#4.4#5#4.4#5#4.4#5#5#5#5#5#3
###################################################################################################
5#8#8#8#8#7#8#8#8#8#8#8#8#8#7.7#8#8#8#8#8#8#7#7.7#8#8#8#8#7.7#8#8#8#7#8#8#8#7.7#8#8#8#8#7.7#8#7....

result:

ok Correct.

Test #25:

score: 0
Accepted
time: 2ms
memory: 7828kb

input:

50 50
2.5.5.5.5.5.5.5.5.5.5.5.4.4.4.4.5.4.4.4.4.4.4.5.5.5.4.4.5.5.4.4.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.5.5.3
...................................................................................................
4.7.7.7.7.7.8.8.8.8.7.7.8.8.8.8.7.7.8.7.7.8.8.8.7.7.8.7.8.8.8.7.7.8.8.7.7.7.7.7.8.8.7.7.8.8.8....

output:

NO

result:

ok Correct.

Test #26:

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

input:

50 50
2.4.4.5.5.5.5.5.5.5.5.5.4.4.5.5.5.4.4.5.5.5.5.5.5.5.5.4.4.5.4.4.5.5.5.5.5.5.4.4.5.4.4.4.4.4.4.5.5.3
...................................................................................................
4.8.7.7.7.7.7.8.7.7.7.7.8.7.7.7.8.7.8.7.7.7.7.8.8.8.8.8.8.8.8.7.7.8.7.8.8.8.8.8.8.8.7.8.8.8.8....

output:

NO

result:

ok Correct.

Test #27:

score: 0
Accepted
time: 4ms
memory: 9824kb

input:

50 50
3.5.4.4.4.4.5.4.4.5.4.4.5.5.5.5.5.5.4.4.5.4.4.5.5.5.4.4.5.5.5.4.4.5.5.5.5.5.5.4.4.4.4.4.4.5.5.4.4.3
...................................................................................................
5.8.7.8.8.8.7.7.8.7.7.8.8.8.7.7.8.7.8.8.8.8.7.8.8.8.8.7.7.8.8.7.7.8.7.7.7.7.7.7.8.8.7.7.8.7.7....

output:

NO

result:

ok Correct.

Test #28:

score: 0
Accepted
time: 2ms
memory: 7836kb

input:

50 50
3.5.4.4.5.4.4.5.5.5.4.4.5.5.4.4.4.4.4.4.5.5.5.5.4.4.5.5.5.5.4.4.5.5.5.5.4.4.5.4.4.5.5.4.4.5.4.4.5.3
...................................................................................................
4.8.8.8.7.8.7.7.7.7.8.8.8.7.7.8.8.8.7.8.8.8.8.8.8.8.7.7.8.7.8.8.7.7.8.7.7.7.7.8.8.7.8.7.7.7.7....

output:

YES
3#5#4.4#5#4.4#5#5#5#4.4#5#5#4.4#4.4#4.4#5#5#5#5#4.4#5#5#5#5#4.4#5#5#5#5#4.4#5#4.4#5#5#4.4#5#4.4#5#3
###################################################################################################
4#8#8#8#7#8#7.7#7.7#8#8#8#7.7#8#8#8#7#8#8#8#8#8#8#8#7.7#8#7#8#8#7.7#8#7.7#7.7#8#8#7#8#7.7#7.7#7....

result:

ok Correct.

Test #29:

score: 0
Accepted
time: 4ms
memory: 7844kb

input:

50 50
3.5.4.4.4.4.5.5.4.4.4.4.5.4.4.4.4.4.5.4.4.4.4.5.5.4.4.5.5.5.5.4.4.5.5.5.5.5.4.4.5.4.4.4.4.5.5.5.5.3
...................................................................................................
4.8.8.7.7.8.8.8.8.8.8.8.7.7.7.8.8.8.8.7.7.8.8.7.7.7.7.7.7.7.7.8.8.7.7.7.7.7.7.7.7.7.8.7.7.7.8....

output:

NO

result:

ok Correct.

Test #30:

score: 0
Accepted
time: 4ms
memory: 7900kb

input:

50 50
2.4.4.5.5.4.4.5.4.4.4.4.5.4.4.4.4.5.5.4.4.5.5.5.5.5.5.4.4.5.4.4.4.4.5.4.4.4.4.4.4.5.4.4.5.5.4.4.5.2
...................................................................................................
4.7.7.7.8.8.8.7.7.7.8.8.8.8.8.8.8.7.7.8.8.8.7.7.7.8.8.7.7.7.7.7.7.7.8.7.7.8.8.8.7.7.8.8.8.7.8....

output:

YES
2#4.4#5#5#4.4#5#4.4#4.4#5#4.4#4.4#5#5#4.4#5#5#5#5#5#5#4.4#5#4.4#4.4#5#4.4#4.4#4.4#5#4.4#5#5#4.4#5#2
.#################################################################################################.
4#7.7#7#8#8#8#7.7#7#8#8#8#8#8#8#8#7.7#8#8#8#7#7.7#8#8#7#7.7#7.7#7.7#8#7.7#8#8#8#7.7#8#8#8#7#8#7....

result:

ok Correct.

Test #31:

score: 0
Accepted
time: 4ms
memory: 7824kb

input:

50 50
3.4.4.5.5.5.5.5.4.4.5.4.4.5.4.4.5.4.4.5.5.5.4.4.4.4.5.4.4.4.4.5.4.4.5.5.4.4.5.4.4.5.5.4.4.5.5.4.4.3
...................................................................................................
5.7.8.7.7.8.7.7.8.7.7.8.7.7.8.7.7.8.7.8.7.8.7.7.7.7.7.7.8.8.8.8.8.7.8.8.8.8.7.7.7.7.8.8.8.7.7....

output:

YES
3#4.4#5#5#5#5#5#4.4#5#4.4#5#4.4#5#4.4#5#5#5#4.4#4.4#5#4.4#4.4#5#4.4#5#5#4.4#5#4.4#5#5#4.4#5#5#4.4#3
###################################################################################################
5#7#8#7.7#8#7.7#8#7.7#8#7.7#8#7.7#8#7#8#7#8#7.7#7.7#7.7#8#8#8#8#8#7#8#8#8#8#7.7#7.7#8#8#8#7.7#8#...

result:

ok Correct.

Test #32:

score: 0
Accepted
time: 0ms
memory: 7928kb

input:

50 50
3.4.4.5.4.4.5.4.4.5.5.5.5.4.4.4.4.5.4.4.5.5.4.4.5.5.4.4.5.5.4.4.4.4.4.4.4.4.5.5.4.4.5.5.5.5.4.4.4.2
...................................................................................................
5.7.7.8.7.7.8.7.7.7.8.7.7.8.8.8.8.8.7.7.7.7.7.7.7.7.7.7.7.7.8.7.8.8.8.8.8.7.7.8.8.7.7.8.8.8.8....

output:

YES
3#4.4#5#4.4#5#4.4#5#5#5#5#4.4#4.4#5#4.4#5#5#4.4#5#5#4.4#5#5#4.4#4.4#4.4#4.4#5#5#4.4#5#5#5#5#4.4#4.2
###################################################################################################
5#7.7#8#7.7#8#7#7.7#8#7.7#8#8#8#8#8#7#7.7#7#7.7#7#7.7#7#7.7#8#7#8#8#8#8#8#7.7#8#8#7.7#8#8#8#8#8#...

result:

ok Correct.

Test #33:

score: 0
Accepted
time: 1ms
memory: 7884kb

input:

50 50
2.4.4.4.4.4.4.5.4.4.4.4.5.4.4.4.4.5.4.4.4.4.5.5.5.4.4.5.4.4.5.4.4.4.4.5.5.4.4.4.4.5.5.5.5.5.4.4.5.3
...................................................................................................
4.8.7.7.8.7.7.7.7.7.8.7.7.7.7.7.8.7.8.7.8.7.7.8.7.8.8.7.7.7.8.8.7.8.7.7.7.7.7.7.7.8.8.7.8.8.8....

output:

YES
2#4.4#4.4#4.4#5#4.4#4.4#5#4.4#4.4#5#4.4#4.4#5#5#5#4.4#5#4.4#5#4.4#4.4#5#5#4.4#4.4#5#5#5#5#5#4.4#5#3
.##################################################################################################
4#8#7.7#8#7.7#7#7.7#8#7#7.7#7.7#8#7#8#7#8#7.7#8#7#8#8#7#7.7#8#8#7#8#7.7#7#7.7#7.7#8#8#7#8#8#8#8#...

result:

ok Correct.

Test #34:

score: 0
Accepted
time: 4ms
memory: 7944kb

input:

50 50
2.4.5.5.4.4.4.4.4.4.5.4.4.5.4.4.5.4.4.5.5.4.4.5.5.4.4.4.4.4.4.5.5.5.5.5.4.4.4.4.5.5.5.4.4.5.5.4.4.3
...................................................................................................
5.8.8.7.7.7.8.7.7.8.8.7.7.8.7.7.7.7.7.7.7.7.8.7.8.7.7.7.7.7.7.8.8.7.7.8.8.7.7.7.7.8.8.8.8.8.8....

output:

YES
2.4#5#5#4.4#4.4#4.4#5#4.4#5#4.4#5#4.4#5#5#4.4#5#5#4.4#4.4#4.4#5#5#5#5#5#4.4#4.4#5#5#5#4.4#5#5#4.4#3
###################################################################################################
5#8#8#7#7.7#8#7.7#8#8#7#7#8#7.7#7.7#7.7#7.7#8#7#8#7#7.7#7.7#7#8#8#7.7#8#8#7.7#7.7#8#8#8#8#8#8#7....

result:

ok Correct.

Test #35:

score: 0
Accepted
time: 2ms
memory: 7896kb

input:

50 50
3.5.5.4.4.4.4.5.4.4.4.4.4.4.4.4.5.4.4.5.4.4.5.4.4.5.4.4.4.4.5.5.4.4.4.4.4.4.5.5.5.5.4.4.5.4.4.4.4.2
...................................................................................................
5.7.8.7.7.7.8.8.8.8.8.7.8.7.7.7.7.8.8.8.7.7.7.7.7.8.7.7.7.7.7.7.7.7.7.8.7.8.7.7.7.7.7.7.7.7.7....

output:

YES
3#5#5#4.4#4.4#5#4.4#4.4#4.4#4.4#5#4.4#5#4.4#5#4.4#5#4.4#4.4#5#5#4.4#4.4#4.4#5#5#5#5#4.4#5#4.4#4.4#2
##################################################################################################.
5#7#8#7.7#7#8#8#8#8#8#7#8#7.7#7#7#8#8#8#7#7.7#7.7#8#7#7.7#7.7#7.7#7.7#8#7#8#7.7#7.7#7.7#7.7#7.7#...

result:

ok Correct.

Test #36:

score: 0
Accepted
time: 4ms
memory: 7764kb

input:

50 50
3.4.4.4.4.5.4.4.5.4.4.4.4.5.4.4.4.4.4.4.4.4.4.4.4.4.5.5.4.4.4.4.4.4.5.4.4.4.4.5.4.4.4.4.5.4.4.4.4.3
...................................................................................................
5.7.7.7.7.8.7.7.7.7.7.7.7.7.8.8.8.8.7.7.7.8.7.7.8.8.7.7.7.8.7.7.7.8.7.7.7.7.7.7.8.8.8.7.7.8.7....

output:

NO

result:

ok Correct.

Test #37:

score: 0
Accepted
time: 4ms
memory: 7824kb

input:

50 50
2.4.4.4.5.5.4.4.4.4.5.5.4.4.5.5.4.4.4.4.4.4.5.5.5.4.4.5.5.5.5.4.4.4.4.4.4.4.4.4.4.4.4.5.5.5.5.4.4.2
...................................................................................................
5.7.7.7.7.7.7.8.7.7.7.7.7.7.8.7.8.7.7.7.7.7.8.8.8.7.7.8.7.8.8.7.8.7.7.7.8.8.8.7.7.8.8.7.7.8.7....

output:

NO

result:

ok Correct.

Test #38:

score: 0
Accepted
time: 4ms
memory: 7948kb

input:

50 50
3.4.4.5.5.4.4.5.5.4.4.5.4.4.4.4.4.4.5.5.4.4.4.4.4.4.5.4.4.5.5.4.4.4.4.4.4.4.4.5.5.5.5.4.4.4.4.4.4.3
...................................................................................................
4.8.7.7.7.7.7.8.8.7.8.7.7.8.8.8.7.7.7.7.8.7.8.7.7.7.7.7.8.7.7.7.7.8.8.8.7.7.8.8.7.8.8.7.7.7.7....

output:

YES
3#4.4#5#5#4.4#5#5#4.4#5#4.4#4.4#4.4#5#5#4.4#4.4#4.4#5#4.4#5#5#4.4#4.4#4.4#4.4#5#5#5#5#4.4#4.4#4.4#3
###################################################################################################
4#8#7.7#7.7#7#8#8#7#8#7#7#8#8#8#7.7#7.7#8#7#8#7#7.7#7.7#8#7.7#7.7#8#8#8#7.7#8#8#7#8#8#7#7.7#7.7#...

result:

ok Correct.

Test #39:

score: 0
Accepted
time: 4ms
memory: 7992kb

input:

50 50
2.4.4.4.4.5.5.4.4.5.5.4.4.4.4.4.4.5.5.4.4.5.4.4.4.4.4.4.4.4.4.4.5.4.4.5.5.5.4.4.4.4.4.4.4.4.5.5.5.2
...................................................................................................
4.8.7.7.8.8.8.7.7.8.7.7.7.7.7.8.7.8.7.7.7.8.7.8.7.8.8.7.7.7.8.7.7.8.7.7.7.7.7.8.7.7.7.8.7.7.8....

output:

YES
2#4.4#4.4#5#5#4.4#5#5#4.4#4.4#4.4#5#5#4.4#5#4.4#4.4#4.4#4.4#4.4#5#4.4#5#5#5#4.4#4.4#4.4#4.4#5#5#5#2
.#################################################################################################.
4#8#7.7#8#8#8#7.7#8#7.7#7.7#7#8#7#8#7.7#7#8#7#8#7#8#8#7#7.7#8#7.7#8#7#7.7#7.7#8#7.7#7#8#7.7#8#7....

result:

ok Correct.

Test #40:

score: 0
Accepted
time: 2ms
memory: 7884kb

input:

50 50
2.5.4.4.4.4.4.4.4.4.4.4.4.4.5.5.4.4.5.5.4.4.4.4.5.4.4.4.4.4.4.5.4.4.4.4.4.4.4.4.4.4.4.4.4.4.5.4.4.2
...................................................................................................
4.7.7.7.7.7.7.7.7.7.8.8.7.8.7.7.7.7.7.8.8.7.7.8.7.8.8.7.7.7.7.7.7.7.7.7.7.7.7.7.8.7.7.8.7.7.8....

output:

YES
2#5#4.4#4.4#4.4#4.4#4.4#4.4#5#5#4.4#5#5#4.4#4.4#5#4.4#4.4#4.4#5#4.4#4.4#4.4#4.4#4.4#4.4#4.4#5#4.4#2
.#################################################################################################.
4#7#7.7#7.7#7.7#7.7#8#8#7#8#7#7.7#7.7#8#8#7.7#8#7#8#8#7.7#7.7#7.7#7.7#7#7.7#7.7#8#7.7#8#7.7#8#7....

result:

ok Correct.

Test #41:

score: 0
Accepted
time: 2ms
memory: 9792kb

input:

50 50
2.4.4.4.4.4.4.4.5.4.4.5.4.4.5.4.4.5.5.4.4.4.4.5.4.4.5.4.4.5.4.4.4.4.5.4.4.4.4.4.4.4.4.4.4.5.4.4.5.3
...................................................................................................
5.7.7.7.7.7.7.7.8.7.7.7.8.7.7.7.8.7.7.8.8.7.8.8.7.7.8.8.7.7.7.8.7.7.7.7.7.7.8.7.7.7.7.7.8.7.7....

output:

YES
2.4#4.4#4.4#4.4#5#4.4#5#4.4#5#4.4#5#5#4.4#4.4#5#4.4#5#4.4#5#4.4#4.4#5#4.4#4.4#4.4#4.4#4.4#5#4.4#5#3
###################################################################################################
5#7.7#7#7.7#7.7#8#7#7.7#8#7.7#7#8#7.7#8#8#7#8#8#7.7#8#8#7.7#7#8#7.7#7.7#7.7#8#7#7.7#7.7#8#7.7#8#...

result:

ok Correct.

Test #42:

score: 0
Accepted
time: 2ms
memory: 8020kb

input:

50 50
2.4.4.4.4.4.5.4.4.4.4.5.4.4.4.4.4.4.4.4.4.4.5.4.4.4.4.5.4.4.5.5.4.4.5.4.4.5.4.4.4.4.5.4.4.4.4.4.4.3
...................................................................................................
4.7.7.7.7.7.7.7.8.7.7.7.7.7.7.7.7.7.8.7.7.8.8.7.8.7.7.8.7.7.8.7.8.7.7.7.7.8.7.7.8.7.7.8.7.8.7....

output:

YES
2.4#4.4#4.4#5#4.4#4.4#5#4.4#4.4#4.4#4.4#4.4#5#4.4#4.4#5#4.4#5#5#4.4#5#4.4#5#4.4#4.4#5#4.4#4.4#4.4#3
###################################################################################################
4#7#7#7.7#7#7.7#8#7.7#7.7#7#7.7#7#7#8#7.7#8#8#7#8#7.7#8#7.7#8#7#8#7.7#7.7#8#7.7#8#7.7#8#7#8#7.7#...

result:

ok Correct.

Test #43:

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

input:

50 50
2.4.4.4.5.4.4.4.4.4.4.5.4.4.5.4.4.4.4.4.4.5.4.4.4.4.5.4.4.4.4.5.4.4.4.4.4.4.4.4.4.4.5.4.4.5.4.4.4.2
...................................................................................................
5.8.7.7.8.8.7.7.8.7.7.8.8.7.7.7.7.7.7.7.7.7.8.7.7.7.7.7.7.7.7.7.7.7.8.7.7.7.7.7.8.7.7.7.7.7.8....

output:

NO

result:

ok Correct.

Test #44:

score: 0
Accepted
time: 4ms
memory: 9836kb

input:

37 48
2.4.5.5.4.4.5.5.5.4.4.4.4.4.4.5.4.4.5.5.5.4.4.4.4.5.5.5.4.4.5.5.4.4.5.5.5.5.5.4.4.5.5.5.5.4.4.3
...............................................................................................
5.7.7.7.7.8.8.8.7.7.8.8.8.7.7.7.8.8.7.7.8.7.8.7.8.8.8.8.8.7.8.7.7.8.8.8.7.7.7.8.8.8.7.7.8.8.7.4
.........

output:

YES
2.4#5#5#4.4#5#5#5#4.4#4.4#4.4#5#4.4#5#5#5#4.4#4.4#5#5#5#4.4#5#5#4.4#5#5#5#5#5#4.4#5#5#5#5#4.4#3
###############################################################################################
5#7#7.7#7#8#8#8#7.7#8#8#8#7#7.7#8#8#7.7#8#7#8#7#8#8#8#8#8#7#8#7.7#8#8#8#7.7#7#8#8#8#7.7#8#8#7#4
##.#####...

result:

ok Correct.

Test #45:

score: 0
Accepted
time: 0ms
memory: 9716kb

input:

14 49
3.5.4.4.5.5.5.4.4.5.4.4.5.4.4.5.5.4.4.5.5.5.4.4.4.4.5.4.4.4.4.4.4.5.5.5.4.4.4.4.4.4.5.5.5.5.5.4.2
.................................................................................................
4.8.7.7.7.7.7.7.7.7.8.7.7.8.8.7.7.8.7.7.8.7.8.7.8.7.7.7.7.8.7.8.7.7.7.8.7.7.7.7.8.8.7.7.7.7.8.7.5
...

output:

YES
3#5#4.4#5#5#5#4.4#5#4.4#5#4.4#5#5#4.4#5#5#5#4.4#4.4#5#4.4#4.4#4.4#5#5#5#4.4#4.4#4.4#5#5#5#5#5#4.2
#################################################################################################
4#8#7.7#7.7#7#7.7#7#8#7#7#8#8#7.7#8#7.7#8#7#8#7#8#7.7#7#7#8#7#8#7#7#7#8#7.7#7.7#8#8#7.7#7.7#8#7#5
.#...

result:

ok Correct.

Test #46:

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

input:

33 27
2.4.5.4.4.4.4.4.4.5.5.4.4.4.4.4.4.5.4.4.5.5.4.4.4.4.3
.....................................................
5.7.7.7.8.7.7.8.8.8.7.7.8.7.7.7.7.8.7.7.8.7.7.7.7.8.4
.....................................................
4.7.7.7.8.7.7.7.7.8.8.7.7.8.8.8.7.7.8.7.7.8.8.8.8.7.4
...........................

output:

YES
2.4#5#4.4#4.4#4.4#5#5#4.4#4.4#4.4#5#4.4#5#5#4.4#4.4#3
#####################################################
5#7#7.7#8#7#7#8#8#8#7.7#8#7.7#7.7#8#7.7#8#7.7#7.7#8#4
##.#######.#.#######################################.
4#7#7.7#8#7#7#7.7#8#8#7.7#8#8#8#7.7#8#7.7#8#8#8#8#7#4
.#########################...

result:

ok Correct.

Test #47:

score: 0
Accepted
time: 2ms
memory: 7644kb

input:

13 26
2.4.5.4.4.4.4.5.4.4.5.5.4.4.5.4.4.5.4.4.5.4.4.4.4.2
...................................................
5.7.7.7.7.8.7.7.7.7.7.7.7.7.7.7.7.7.8.7.7.7.7.7.7.4
...................................................
4.7.7.7.7.7.7.8.7.7.8.8.7.7.7.7.8.7.8.8.8.7.8.7.7.4
.....................................

output:

YES
2.4#5#4.4#4.4#5#4.4#5#5#4.4#5#4.4#5#4.4#5#4.4#4.4#2
##################################################.
5#7#7.7#7#8#7#7.7#7#7.7#7.7#7.7#7.7#8#7.7#7.7#7.7#4
##.#####.###.#####.################################
4#7#7.7#7#7#7#8#7#7#8#8#7#7#7.7#8#7#8#8#8#7#8#7.7#4
.#########.#####.#######.#.#######.#...

result:

ok Correct.

Test #48:

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

input:

45 7
2.4.5.4.4.5.2
.............
4.7.7.7.7.7.4
.............
4.7.7.7.7.7.5
.............
4.8.8.7.7.7.5
.............
4.7.7.7.7.8.4
.............
4.7.8.7.7.7.4
.............
4.7.8.7.8.7.5
.............
4.7.7.7.7.7.4
.............
4.8.8.7.8.8.4
.............
5.7.7.8.7.7.4
.............
4.7.7.7.7.7.4
....

output:

YES
2.4#5#4.4#5#2
############.
4#7#7.7#7.7#4
.#.##########
4#7#7.7#7.7#5
#############
4#8#8#7#7.7#5
.#####.######
4#7.7#7#7#8#4
########.###.
4#7#8#7#7#7#4
.#.###.###.##
4#7#8#7#8#7#5
#############
4#7.7#7#7.7#4
.#####.#####.
4#8#8#7#8#8#4
#############
5#7.7#8#7.7#4
############.
4#7#7#7.7#7#4
.#...

result:

ok Correct.

Test #49:

score: 0
Accepted
time: 4ms
memory: 9908kb

input:

48 36
2.5.5.4.4.4.4.5.4.4.5.5.4.4.5.5.5.5.4.4.4.4.5.5.5.5.5.4.4.4.4.5.5.5.5.3
.......................................................................
4.8.8.7.7.7.8.8.8.8.8.8.7.7.8.8.7.7.7.7.7.8.8.8.8.8.7.7.7.7.7.8.7.8.8.4
.......................................................................
4.8.8....

output:

YES
2#5#5#4.4#4.4#5#4.4#5#5#4.4#5#5#5#5#4.4#4.4#5#5#5#5#5#4.4#4.4#5#5#5#5#3
.######################################################################
4#8#8#7.7#7#8#8#8#8#8#8#7.7#8#8#7.7#7.7#7#8#8#8#8#8#7.7#7#7.7#8#7#8#8#4
##########.#############################.###############.#######.#####.
4#8#8#7#...

result:

ok Correct.

Test #50:

score: 0
Accepted
time: 0ms
memory: 7600kb

input:

2 2
3.3
...
3.3

output:

YES
3#3
###
3#3

result:

ok Correct.

Test #51:

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

input:

2 2
2.3
...
2.3

output:

YES
2#3
.##
2#3

result:

ok Correct.

Test #52:

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

input:

2 5
2.4.4.5.2
.........
2.5.4.4.2

output:

YES
2#4.4#5#2
.#######.
2#5#4.4#2

result:

ok Correct.

Test #53:

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

input:

5 2
2.2
...
4.4
...
5.5
...
5.4
...
3.2

output:

YES
2#2
.#.
4#4
###
5#5
###
5#4
##.
3#2

result:

ok Correct.

Test #54:

score: 0
Accepted
time: 2ms
memory: 7636kb

input:

5 2
2.2
...
4.5
...
4.5
...
5.4
...
3.2

output:

YES
2.2
###
4#5
.##
4#5
###
5#4
##.
3#2

result:

ok Correct.