QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202177 | #4432. Jungle Trail | Forever_Young# | WA | 110ms | 45408kb | C++23 | 1.9kb | 2023-10-05 20:27:43 | 2023-10-05 20:27:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n;i>=1;i--)
#define mp make_pair
#define pb push_back
int n,m;
char s[2100][2100];
bool f[2100][2100];
int row[2100],col[2100];
pair<int,int> pre[2100][2100];
int main()
{
int T;
cin>>T;
while (T--)
{
scanf("%d%d",&n,&m);
rep(i,n)scanf("%s",s[i]+1);
rep(i,n)rep(j,m)f[i][j]=0;
if (f[1][1]!='#')f[1][1]=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if (i==1 && j==1)
if (f[1][1]!='#')f[1][1]=1;
if (i>1 && f[i-1][j]==1)pre[i][j]=mp(i-1,j),f[i][j]=1;
if (i>1 && f[i][j-1]==1)pre[i][j]=mp(i,j-1),f[i][j]=1;
if (s[i][j]=='#')f[i][j]=0;
}
if (f[n][m]==0)puts("NIE");
else
{
puts("TAK");
static vector<char> ans; ans.clear();
int nowx=n,nowy=m;
while (nowx!=1 || nowy!=1)
{
if (nowx==pre[nowx][nowy].first)ans.pb('P'); else ans.pb('D');
tie(nowx,nowy)=pre[nowx][nowy];
}
reverse(ans.begin(),ans.end());
nowx=1,nowy=1;
for(int i=1;i<=n;i++)row[i]=-1;
for(int i=1;i<=m;i++)col[i]=-1;
if (s[1][1]=='@')row[1]=1;
for(auto p:ans)
{
if (p=='P')nowy++; else nowx++;
int f=0; if (s[nowx][nowy]=='@')f=1;
if (row[nowx]==1)f^=1;
if (col[nowy]==1)f^=1;
if (f)
{
if (p=='D')row[nowx]=1;
else col[nowy]=1;
}
}
for(int i=1;i<=n;i++)if (row[i]==1)putchar('T'); else putchar('N'); puts("");
for(int i=1;i<=m;i++)if (col[i]==1)putchar('T'); else putchar('N'); puts("");
/*
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if (s[i][j]=='.' || s[i][j]=='#'){ putchar(s[i][j]); continue; }
int f; if (s[i][j]=='@')f=1; else f=0;
if (row[i]==1)f^=1;
if (col[j]==1)f^=1;
if (f==1)putchar('@'); else putchar('O');
}
puts("");
}*/
for(auto p:ans)putchar(p); puts("");
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 110ms
memory: 45408kb
input:
486 4 5 ..#.. @@O@@ ##@#O ..@.@ 2 2 OO OO 2 2 @@ @@ 2 2 @@ #@ 2 2 @O #@ 2 2 @@ OO 2 2 O# @O 2 2 @# #@ 2 2 @. .@ 2 2 @# .O 2 2 OO .O 10 10 @O@O#O@@@# OO#@#@@#OO #@#@#O##O@ OO##@@O#@O O##@@#@O#@ OO@OO@@@O@ @O#@#@O#@O @OOOOO@##. O@OOO##O@@ OO@@OOOO#@ 10 10 @@#OOO#O@@ #@@OO@@.O@ #.O@@O#@@O OO@@#O@#O@ .#...
output:
TAK NTNN NNTNT DPPDDPP TAK NN NN DP TAK TT NN DP NIE NIE TAK TN NN DP TAK NT NT DP NIE TAK TN NT DP TAK TN NN DP TAK NN NN DP NIE NIE TAK NTTTNTNNNN NTTTNTNTTN DDDDDPDDDPPPPPDPPP TAK NNNTNTTTNT NNTTTTTNNT DDDPPDPDDDDDPPPPPP TAK NNNTNNNTNT NNNNNTTTNT DDDPPDDPDPDPPPDPPD NIE TAK TTTTTNTNNT NTNNNTTNNN D...
result:
wrong answer you didn't find a solution but jury did (test case 4)