QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#540132 | #8935. Puzzle: Easy as Scrabble | ucup-team3510# | WA | 1ms | 5892kb | C++20 | 1.0kb | 2024-08-31 16:29:18 | 2024-08-31 16:29:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n,m;char s[1011][1011];
int has[1011][1011];
//U:1 L:2 D:4 R:8
void mark(int i,int j,char c,int dir);
void implode(int x,int y)
{
if(has[x][y]&1)mark(x+1,y,s[0][y],0);
if(has[x][y]&2)mark(x,y+1,s[x][0],1);
if(has[x][y]&4)mark(x-1,y,s[n+1][y],2);
if(has[x][y]&8)mark(x,y-1,s[x][m+1],4);
has[x][y]=0;s[x][y]='x';
}
void mark(int i,int j,char c,int dir)
{
if(i<=0||i>n||j<=0||j>m){printf("NO\n");exit(0);}
has[i][j]|=1<<dir;
if(s[i][j]!='.'&&s[i][j]!=c)implode(i,j);
else s[i][j]=c;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=0;i<=n+1;++i)scanf("%s",s[i]);
for(int i=1;i<=n;++i)
{
if(s[i][0]!='.')mark(i,1,s[i][0],1);
if(s[i][m+1]!='.')mark(i,m,s[i][m+1],3);
}
for(int i=1;i<=m;++i)
{
if(s[0][i]!='.')mark(1,i,s[0][i],0);
if(s[n+1][i]!='.')mark(n,i,s[n+1][i],2);
}
printf("YES\n");
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
if(s[i][j]=='x')putchar('.');
else putchar(s[i][j]);
}
putchar(10);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5892kb
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: 3832kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
YES U.NX. .O..X M.... .VB.S .I.HX
result:
wrong answer Row 3 right clue not satisfied.