QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310380#6398. Puzzle: TapaPlentyOfPenalty#WA 0ms3872kbC++204.3kb2024-01-21 12:04:442024-01-21 12:04:44

Judging History

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

  • [2024-01-21 12:04:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-01-21 12:04:44]
  • 提交

answer

#include<bits/stdc++.h>
#define QUIT exit((puts("NO"),0))
using namespace std;
const int N=100;
int n,m,mp[N+10][N+10],tv[N+10][N+10],fl;
char tmp[N+10][N+10],prt[N+10][N+10];
void Solve(int xl,int yl,int xr,int yr){
	if(xr==xl){
		if(yr==yl){
			if(mp[xl][yl])QUIT;
			return;
		}
		for(int i=yl+1;i<yr;i+=2){
			if(mp[xl][i-1]){
				prt[xl][i]='.';
				if(!mp[xl][i+1])QUIT;
				mp[xl][i+1]=0;
			}else prt[xl][i]='#';
		}
		return;
	}
	if(xr-xl==2)for(int j=yl+1;j<yr;++j)prt[xl+1][j]='#';
	else{
		for(int i=xl+1;i<xr;++i)prt[i][yl+1]=prt[i][yr-1]='#';
		for(int i=yl+1;i<yr;++i)prt[xl+1][i]=prt[xr-1][i]='#';
		Solve(xl+2,yl+2,xr-2,yr-2);
	}
	//cout<<"SOLVE["<<xl<<","<<xr<<"] ["<<yl<<","<<yr<<"]\n";
	for(int i=xl;i<=xr;++i)tv[i][yl]=mp[i][yl],tv[i][yr]=mp[i][yr];
	for(int i=yl;i<=yr;++i)tv[xl][i]=mp[xl][i],tv[xr][i]=mp[xr][i];
	//for(int i=xl;i<=xr;++i,puts(""))for(int j=yl;j<=yr;++j)cout<<(char)(tv[i][j]+'0');
	for(int i=xl+1;i<xr;i+=2){
		if(tv[i-1][yl]){
			tv[i-1][yl]=0;
			prt[i][yl]='.';
			//cout<<"DEL "<<i<<" "<<yl<<"\n";
			if(!tv[i+1][yl])goto Skip;
			tv[i+1][yl]=0;
		}else prt[i][yl]='#';
	}
	for(int i=yl+1;i<yr;i+=2){
		if(tv[xr][i-1]){
			tv[xr][i-1]=0;
			prt[xr][i]='.';
			//cout<<"DEL "<<xr<<" "<<i<<"\n";
			if(!tv[xr][i+1])goto Skip;
			tv[xr][i+1]=0;
		}else prt[xr][i]='#';
	}
	for(int i=xr-1;i>xl;i-=2){
		if(tv[i+1][yr]){
			tv[i+1][yr]=0;
			prt[i][yr]='.';
			//cout<<"DEL "<<i<<" "<<yr<<"\n";
			if(!tv[i-1][yr])goto Skip;
			tv[i-1][yr]=0;
		}else prt[i][yr]='#';
	}
	for(int i=yr-1;i>yl;i-=2){
		if(tv[xl][i+1]){
			tv[xl][i+1]=0;
			prt[xl][i]='.';
			if(!tv[xl][i-1])goto Skip;
			tv[xl][i-1]=0;
		}else prt[xl][i]='#';
	}
	return;
	Skip:
	//cout<<"SKIP.\n";
	for(int i=xl;i<=xr;++i)tv[i][yl]=mp[i][yl],tv[i][yr]=mp[i][yr];
	for(int i=yl;i<=yr;++i)tv[xl][i]=mp[xl][i],tv[xr][i]=mp[xr][i];
	//for(int i=xl;i<=xr;++i,puts(""))for(int j=yl;j<=yr;++j)cout<<(char)(tv[i][j]+'0');
	for(int i=yl+1;i<yr;i+=2){
		if(tv[xl][i-1]){
			tv[xl][i-1]=0;
			prt[xl][i]='.';
			if(!tv[xl][i+1])QUIT;
			tv[xl][i+1]=0;
		}else prt[xl][i]='#';
	}
	for(int i=xl+1;i<xr;i+=2){
		if(tv[i-1][yr]){
			tv[i-1][yr]=0;
			prt[i][yr]='.';
			if(!tv[i+1][yr])QUIT;
			tv[i+1][yr]=0;
		}else prt[i][yr]='#';
	}
	for(int i=yr-1;i>yl;i-=2){
		if(tv[xr][i+1]){
			tv[xr][i+1]=0;
			prt[xr][i]='.';
			if(!tv[xr][i-1])QUIT;
			tv[xr][i-1]=0;
		}else prt[xr][i]='#';
	}
	for(int i=xr-1;i>xl;i-=2){
		if(tv[i+1][yl]){
			tv[i+1][yl]=0;
			prt[i][yl]='.';
			if(!tv[i-1][yl])QUIT;
			tv[i-1][yl]=0;
		}else prt[i][yl]='#';
	}
}
const int d[8][2]={{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1},{0,1},{1,1}};
int main(){
	//cin.sync_with_stdio(0),cin.tie(0);
	//cin>>n>>m;
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m),fl=1;
	if(fl){
		for(int i=1;i<(m<<1);++i)scanf("%s",tmp[i]+1);
		for(int i=1;i<(n<<1);++i)for(int j=1;j<(m<<1);++j)mp[i][j]=tmp[j][i]-'0',prt[i][j]=tmp[j][i];
	}else{
		for(int i=1;i<(n<<1);++i)scanf("%s",tmp[i]+1);
		for(int i=1;i<(n<<1);++i)for(int j=1;j<(m<<1);++j)mp[i][j]=tmp[i][j]-'0',prt[i][j]=tmp[i][j];
	}
	for(int i=1;i<(n<<1);i+=2)for(int j=1;j<(m<<1);j+=2)mp[i][j]=(mp[i][j]==2||mp[i][j]==4||mp[i][j]==7);
	Solve(1,1,(n<<1)-1,(m<<1)-1);
	puts("YES");
	if(fl){
		for(int i=1;i<(m<<1);++i){
			for(int j=1;j<(n<<1);++j)putchar(prt[j][i]);
			putchar('\n');
		}
	}else{
		for(int i=1;i<(n<<1);++i){
			for(int j=1;j<(m<<1);++j)putchar(prt[i][j]);
			putchar('\n');
		}
	}
	int tot,tg,ls;
	for(int i=1;i<(n<<1);i+=2)for(int j=1;j<(m<<1);j+=2){
		tot=0,tg=0,ls=-1;
		//cout<<"in ("<<i<<","<<j<<")\n";
		for(int k=0;k<8;++k)if(i+d[k][0]>0&&i+d[k][0]<(n<<1)&&j+d[k][1]>0&&j+d[k][1]<(m<<1)){
			//cout<<"("<<i+d[k][0]<<","<<j+d[k][1]<<")\n";
			if(prt[i+d[k][0]][j+d[k][1]]=='#'){
				++tot;
				if(ls!=1)++tg,ls=1;
			}else{
				if(ls)++tg,ls=0;
			}
		}else if(ls)++tg,ls=0;
		//cout<<"TT="<<tot<<"p="<<prt[i][j]<<"\n";
		assert(tot==prt[i][j]-'0');
		assert(tg<=3);
	}
	return 0;
}
/*
3 3
2.4.3
.....
5.7.5
.....
3.5.3

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

2 3
2.4.2
.....
2.4.2

3 2
3.3
...
5.5
...
3.3

4 4
3.5.5.3
.......
5.7.8.5
.......
5.7.7.5
.......
3.5.5.3

5 4
2.4.5.3
.......
5.8.8.5
.......
5.8.8.4
.......
5.8.8.4
.......
3.4.4.3

4 5
2.5.5.5.3
.........
4.8.8.8.4
.........
5.8.8.8.4
.........
3.5.4.4.3
*/

詳細信息

Test #1:

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

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

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

input:

2 2
2.2
...
2.2

output:

YES
2#2
.#.
2#2

result:

ok Correct.

Test #4:

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

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

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

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

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

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

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

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

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: -100
Wrong Answer
time: 0ms
memory: 3824kb

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:

NO

result:

wrong answer Jury has answer but participant has not.