QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100789 | #4432. Jungle Trail | Yanagi_Origami# | WA | 356ms | 67172kb | C++20 | 3.5kb | 2023-04-28 08:54:30 | 2023-04-28 08:54:34 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int N=2005;
char mp[N][N];
int n,m,k,f[N][N][2][2];
vector<char>ans1,ans2,ans3;
void getans(int x,int y,int u,int v){
if(x==1&&y==1) return ;
//printf("#%d %d %d %d\n",x,y,u,v);
if(f[x][y][u][v]==1){
rep(i,0,1){
if(f[x][y-1][i][v]){
getans(x,y-1,i,v);
ans2.push_back(i?'T':'N');
ans3.push_back('P');
break;
}
}
}else{
rep(i,0,1){
if(f[x-1][y][u][i]){
getans(x-1,y,u,i);
ans1.push_back(i?'T':'N');
ans3.push_back('D');
break;
}
}
}
}
void solve(){
scanf("%d%d",&n,&m);
rep(i,1,n){
scanf("%s",mp[i]+1);
}
if(mp[1][1]=='.'){
f[1][1][0][0] = 1;
f[1][1][1][1] = 1;
}else{
f[1][1][0][1] = 1;
f[1][1][1][0] = 1;
}
rep(i,1,n){
rep(j,1,m){
if(j<m&&mp[i][j+1]!='#'){//1 => j+1 2=>i+1
if(mp[i][j+1]=='.'){
if(f[i][j][0][0]||f[i][j][1][0])
f[i][j+1][0][0] = 1,
f[i][j+1][1][0] = 1;
if(f[i][j][0][1]||f[i][j][1][1])
f[i][j+1][0][1] = 1,
f[i][j+1][1][1] = 1;
}else{
if(mp[i][j+1]=='O'){
if(f[i][j][0][0]||f[i][j][1][0])
f[i][j+1][0][0] = 1;
if(f[i][j][0][1]||f[i][j][1][1])
f[i][j+1][1][1] = 1;
}else{
if(f[i][j][0][0]||f[i][j][1][0])
f[i][j+1][1][0] = 1;
if(f[i][j][0][1]||f[i][j][1][1])
f[i][j+1][0][1] = 1;
}
}
}
if(i<n&&mp[i+1][j]!='#'){
if(mp[i+1][j]=='.'){
if(f[i][j][0][0]||f[i][j][0][1])
f[i+1][j][0][0] = 2,
f[i+1][j][0][1] = 2;
if(f[i][j][1][0]||f[i][j][1][1])
f[i+1][j][1][0] = 2,
f[i+1][j][1][1] = 2;
}else{
if(mp[i+1][j]=='O'){
if(f[i][j][0][0]||f[i][j][0][1])
f[i+1][j][0][0] = 2;
if(f[i][j][1][0]||f[i][j][1][1])
f[i+1][j][1][1] = 2;
}else{
if(f[i][j][0][0]||f[i][j][0][1])
f[i+1][j][0][1] = 2;
if(f[i][j][1][0]||f[i][j][1][1])
f[i+1][j][1][0] = 2;
}
}
}
}
}
rep(i,0,1) rep(j,0,1) if(f[n][m][i][j]){
puts("TAK");
getans(n,m,i,j);
ans2.push_back(i?'T':'N');
ans1.push_back(j?'T':'N');
for(auto v:ans1) putchar(v); puts("");
for(auto v:ans2) putchar(v); puts("");
for(auto v:ans3) putchar(v); puts("");
return ;
}
puts("NIE");
}
int main(){
int T;
scanf("%d",&T);
while(T--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 356ms
memory: 67172kb
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 TNTT TTNNN DPPDDPP TAK TNTTNN TTNNNNN DPPDDPPDP TAK TNTTNNNN TTNNNNNNN DPPDDPPDPDP TAK TNTTNNNNNN TTNNNNNNNNN DPPDDPPDPDPDP TAK TNTTNNNNNNNN TTNNNNNNNNNNN DPPDDPPDPDPDPDP TAK TNTTNNNNNNNNNN TTNNNNNNNNNNNNN DPPDDPPDPDPDPDPDP TAK TNTTNNNNNNNNNNNN TTNNNNNNNNNNNNNNN DPPDDPPDPDPDPDPDPDP TAK TNTTNNNNN...
result:
wrong answer the length of the first line should be 2 (test case 2)