QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#614358#8935. Puzzle: Easy as ScrabbletreasuresgcWA 0ms3616kbC++231.7kb2024-10-05 16:15:332024-10-05 16:15:34

Judging History

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

  • [2024-10-05 16:15:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-10-05 16:15:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int sum=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}
	while(isdigit(ch)){sum=sum*10+ch-48;ch=getchar();}
	return sum*f;
}
inline char gc()
{
	char ch=getchar();
	while(ch!='x'&&ch!='.'&&!isupper(ch)) ch=getchar();
	return ch;
}
char a[1005][1005];
char ans[1005][1005];
signed main()
{
	int n,m;
	n=read();m=read();
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=m+1;j++)
			a[i][j]=gc(),ans[i][j]='.';
	for(int i=1;i<=n;i++)
	{
		int L=m+2,R=-1;
		if(a[i][0]!='.')
		{
			for(int j=1;j<=m;j++)
			{
				if(a[i][j]=='x') continue;
				if(a[0][j]==a[i][0] || a[0][j]=='.')
				{
					L=j;
					break;
				}
			}
		}
		else L=0;
		if(a[i][m+1]!='.')
		{
			for(int j=m;j>=1;j--)
			{
				if(a[i][j]=='x') continue;
				if(a[0][j]==a[i][0] || a[0][j]=='.') 
				{
					R=j;
					break;
				}
			}
		}
		else R=m+1;
		
		if(L>R || (L==R && a[i][0]!=a[i][m+1]))
		{
			puts("NO");
			return 0;
		}
		
		if(a[i][0]!='.') ans[i][L]=a[i][0];
		if(a[i][m+1]!='.') ans[i][R]=a[i][m+1];
		
		for(int j=L+1;j<R;j++)
		{
			if(a[i][j]=='x') continue;
			if(a[0][j]!='.') ans[i][j]=a[0][j],a[0][j]='.';
			else a[i][j]=a[n+1][j];
		}
	}
	
	for(int j=1;j<=m;j++)
	{
		if(a[0][j]!='.') {puts("NO");return 0;}
		if(a[n+1][j]=='.') continue;
		bool g=0;
		for(int i=n;i>=1;i--)
		{
			if(ans[i][j]=='.') continue;
			if(ans[i][j]==a[n+1][j])
			{
				g=1;
				break;
			}
			else break;
		}
		if(!g) {puts("NO");return 0;}
	}
	puts("YES");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			cout<<ans[i][j];
		cout<<endl;
	}
	return 0;
}


详细

Test #1:

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

input:

5 5
.CBA...
....x..
..x...C
A.....B
B..x..A
C......
.......

output:

YES
CBA..
....C
A...B
B...A
C....

result:

ok Correct.

Test #2:

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

input:

1 2
....
Nx..
..O.

output:

NO

result:

ok Correct.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3560kb

input:

5 5
.U.N.X.
U....xX
Ox....X
M...xxN
Vx....S
Ix.x..X
..IBHX.

output:

NO

result:

wrong answer Jury has answer but participant has not.