QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#539331 | #8935. Puzzle: Easy as Scrabble | ucup-team052# | WA | 1ms | 10092kb | C++23 | 1.2kb | 2024-08-31 14:32:18 | 2024-08-31 14:32:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005 ;
char s[N][N];
int n,m;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int fl[4][N][N];
queue<pair<int,int>> q;
int isvalid(int x,int y) {return 1<=x&&x<=n&&1<=y&&y<=m;}
void push(int x,int y,int dir,int c)
{
while(s[x][y]=='x'&&isvalid(x,y)) x+=dx[dir],y+=dy[dir];
if(!isvalid(x,y))
{
cout<<"NO\n";
exit(0);
}
fl[dir][x][y]=c;
if(s[x][y]!='.'&&s[x][y]!=c)
{
s[x][y]='x';
q.emplace(x,y);
}
else s[x][y]=c;
}
signed main() {
#ifdef xay5421
freopen("b.in","r",stdin);
#endif
cin>>n>>m;
for(int i=0;i<=n+1;i++) scanf("%s",s[i]);
for(int i=1;i<=m;i++) if(s[0][i]!='.') push(1,i,0,s[0][i]);
for(int i=1;i<=m;i++) if(s[n+1][i]!='.') push(n,i,1,s[n+1][i]);
for(int j=1;j<=n;j++) if(s[j][0]!='.') push(j,1,2,s[j][0]);
for(int j=1;j<=n;j++) if(s[j][m+1]!='.') push(j,m,3,s[j][m+1]);
while(!q.empty())
{
auto [x,y]=q.front(); q.pop();
for(int j=0;j<4;j++) if(fl[j][x][y])
{
push(x,y,j,fl[j][x][y]);
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(s[i][j]=='x') s[i][j]='.';
putchar(s[i][j]);
}
putchar('\n');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 10092kb
input:
5 5 .CBA... ....x.. ..x...C A.....B B..x..A C...... .......
output:
CBA.. ....C A...B B...A C....
result:
wrong answer YES or NO expected in answer, but CBA.. found.