QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#104002#6398. Puzzle: TapaHe_Ren#AC ✓3ms3968kbC++143.5kb2023-05-08 10:24:362023-05-08 10:24: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-05-08 10:24:37]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3968kb
  • [2023-05-08 10:24:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 100 + 5;
const int inf = 0x3f3f3f3f;
const int dx[] = {1,-1,0,0};
const int dy[] = {0,0,1,-1};

template<const int MAXN,const int MAXM>
struct Max_Flow
{
	struct Edge
	{
		int next,to,flow;
	}e[MAXM<<1];
	int head[MAXN],etot;
	inline void add_one(int u,int v,int flow)
	{
		e[++etot] = (Edge){ head[u],v,flow};
		head[u] = etot;
	}
	inline void add_edge(int u,int v,int flow){ add_one(u,v,flow); add_one(v,u,0);}
	
	int n,s,t;
	int dep[MAXN], cur[MAXN];
	inline void init(int _n,int _s,int _t){ n=_n; s=_s; t=_t;}
	inline void clear(void){ etot = -1; memset(head,-1,sizeof(head));}
	Max_Flow(void){ clear();}
	inline bool bfs(void)
	{
		for(int i=1; i<=n; ++i) dep[i] = -1, cur[i] = head[i];
		queue<int> q;
		dep[s] = 0; q.push(s);
		while(q.size())
		{
			int u = q.front(); q.pop();
			for(int i=head[u]; ~i; i=e[i].next) if(e[i].flow)
			{
				int v = e[i].to;
				if(dep[v] == -1)
				{
					dep[v] = dep[u] + 1, q.push(v);
					if(v == t) return 1;
				}
			}
		}
		return 0;
	}
	int dfs(int u,int maxf)
	{
		if(u == t || !maxf) return maxf;
		int res = 0;
		for(int &i=cur[u], f; ~i; i=e[i].next)
			if(e[i].flow && dep[e[i].to] == dep[u] + 1 && (f = dfs(e[i].to, min(maxf, e[i].flow))))
			{
				e[i].flow -= f; e[i^1].flow += f;
				res += f; maxf -= f;
				if(!maxf) return res;
			}
		return res;
	}
	ll dinic(void)
	{
		ll res = 0;
		while(bfs()) res += dfs(s,inf);
		return res;
	}
	int getmatch(int u)
	{
		for(int i=head[u]; ~i; i=e[i].next)
			if(e[i].to != s && e[i^1].flow)
				return e[i].to;
		return -1;
	}
};

Max_Flow<MAXN * MAXN, MAXN * MAXN * 5> mf;

char s[MAXN][MAXN];
char ans[MAXN][MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	n = 2 * n - 1;
	m = 2 * m - 1;
	for(int i=1; i<=n; ++i)
		scanf("%s",s[i] + 1);
	
	auto getid = [&] (int i,int j)
	{
		return (i-1) * m + j;
	};
	auto getflag = [&] (int i,int j)
	{
		int flag = 0;
		if(i == 1 || i == n) flag |= 1;
		if(j == 1 || j == m) flag |= 2;
		return flag;
	};
	
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			ans[i][j] = i % 2 == 1 && j % 2 == 1? s[i][j]: '#';
	
	int S = n * m + 1, T = S + 1;
	mf.init(T, S, T);
	
	int tot = 0;
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j+=2)
		{
			int type = (i / 2 + j / 2) % 2;
			int flag = getflag(i,j);
			int need = flag == 3? 3: flag == 1 || flag == 2? 5: 8;
			int cur = need - (s[i][j] - '0');
			
			tot += cur;
			
			if(type == 1)
				mf.add_edge(S, getid(i,j), cur);
			else
				mf.add_edge(getid(i,j), T, cur);
			
			if(type == 1)
			{
				for(int k=0; k<4; ++k)
				{
					int x = i + dx[k] * 2;
					int y = j + dy[k] * 2;
					if(x < 1 || x > n || y < 1 || y > m) continue;
					
					if((flag != 0) ^ (getflag(x,y) != 0)) continue;
					
					if(flag == 1 && dx[k] != 0) continue;
					if(flag == 2 && dy[k] != 0) continue;
					
					mf.add_edge(getid(i,j), getid(x,y), 1);
				}
			}
		}
	
	if(tot % 2 || mf.dinic() != tot / 2)
	{
		printf("NO\n");
		return 0;
	}
	
	for(int i=1; i<=n; i+=2)
		for(int j=1; j<=m; j+=2)
		{
			int type = (i / 2 + j / 2) % 2;
			if(type != 1) continue;
			
			int oth = mf.getmatch(getid(i,j));
			if(oth == -1) continue;
			
			int x = (oth - 1) / m + 1;
			int y = (oth - 1) % m + 1;
			
			ans[(i + x) / 2][(j + y) / 2] = '.';
		}
	
	printf("YES\n");
	for(int i=1; i<=n; ++i)
		printf("%s\n",ans[i] + 1);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3568kb

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: 2ms
memory: 3700kb

input:

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

output:

NO

result:

ok Correct.

Test #3:

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

input:

2 2
2.2
...
2.2

output:

YES
2.2
###
2.2

result:

ok Correct.

Test #4:

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

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: 3668kb

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: 3672kb

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: 0ms
memory: 3648kb

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: 2ms
memory: 3664kb

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: 3676kb

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: 2ms
memory: 3676kb

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: 2ms
memory: 3724kb

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: 0ms
memory: 3644kb

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: 2ms
memory: 3576kb

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: 3608kb

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: 2ms
memory: 3672kb

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: 3676kb

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: 2ms
memory: 3704kb

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: 2ms
memory: 3640kb

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: 0ms
memory: 3712kb

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: 3884kb

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: 2ms
memory: 3904kb

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: 2ms
memory: 3964kb

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: 2ms
memory: 3924kb

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: 2ms
memory: 3952kb

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: 0ms
memory: 3828kb

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: 2ms
memory: 3968kb

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: 2ms
memory: 3884kb

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: 1ms
memory: 3868kb

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: 2ms
memory: 3864kb

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: 2ms
memory: 3888kb

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: 2ms
memory: 3952kb

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: 2ms
memory: 3904kb

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: 3ms
memory: 3916kb

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: 3ms
memory: 3868kb

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: 1ms
memory: 3848kb

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: 2ms
memory: 3784kb

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: 1ms
memory: 3876kb

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: 3ms
memory: 3956kb

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: 3ms
memory: 3848kb

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: 0ms
memory: 3856kb

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: 1ms
memory: 3916kb

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: 3ms
memory: 3856kb

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: 3ms
memory: 3928kb

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: 2ms
memory: 3848kb

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: 2ms
memory: 3728kb

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: 0ms
memory: 3808kb

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: 3700kb

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: 2ms
memory: 3732kb

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: 2ms
memory: 3752kb

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: 2ms
memory: 3656kb

input:

2 2
3.3
...
3.3

output:

YES
3#3
###
3#3

result:

ok Correct.

Test #51:

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

input:

2 2
2.3
...
2.3

output:

YES
2#3
.##
2#3

result:

ok Correct.

Test #52:

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

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: 2ms
memory: 3604kb

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: 3708kb

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.