QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#614413#8935. Puzzle: Easy as ScrabbletreasuresgcWA 0ms3708kbC++231.9kb2024-10-05 16:20:032024-10-05 16:20:05

Judging History

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

  • [2024-10-05 16:20:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-05 16:20:03]
  • 提交

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][m+1] || 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;
		}
		
//		cout<<i<<" "<<L<<" "<<R<<endl;
//		system("pause"); 
		
		
		if(a[i][0]!='.') ans[i][L]=a[i][0],a[0][L]='.';
		if(a[i][m+1]!='.') ans[i][R]=a[i][m+1],a[0][R]='.';
		
		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 ans[i][j]=a[n+1][j];
		}
	}
	
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=m;j++)
//			cout<<ans[i][j];
//		cout<<endl;
//	}
	
	
	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: 3708kb

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

input:

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

output:

NO

result:

ok Correct.

Test #3:

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

input:

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

output:

YES
UINX.
.OBHX
MIN..
.VBHS
.I.HX

result:

ok Correct.

Test #4:

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

input:

10 10
.BAZEMIEKUJ.
A..........K
B..x.x.x..x.
K.........xT
A.x..x.....J
Hx....x....B
Q..x....x.xW
S...x......W
S...x.xxx..Z
...x......xZ
I..x..x.x.xR
.QKO.ID..RW.

output:

NO

result:

wrong answer Jury has answer but participant has not.