QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100790#4432. Jungle TrailYanagi_Origami#WA 369ms70192kbC++203.7kb2023-04-28 08:58:582023-04-28 08:58:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 08:58:58]
  • 评测
  • 测评结果:WA
  • 用时:369ms
  • 内存:70192kb
  • [2023-04-28 08:58:58]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <cstring>
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(){
    //memset(f,0,sizeof(f));
    scanf("%d%d",&n,&m);
    rep(i,1,n) rep(j,1,m) rep(_1,0,1) rep(_2,0,1) f[i][j][_1][_2]=0;
    ans1.clear(); ans2.clear(); ans3.clear();
    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: 369ms
memory: 70192kb

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
TN
NN
DP
TAK
TT
NN
DP
TAK
TT
NN
PD
TAK
NT
TN
PD
TAK
TN
NN
DP
TAK
NN
TN
DP
NIE
TAK
TT
NN
DP
TAK
TN
NN
DP
TAK
TN
NN
DP
NIE
TAK
TTNNTTTTNT
NNTTNNTTNN
PDDDPPDDDDPPDDPPPP
TAK
TTTTNTNNNN
NTTTNTNTTN
DDDDDPDDDPPPPPDPPP
TAK
NNTNTNNNTN
TTNNNNNTTN
DDDPPDPDDDDDPPPPPP
TAK
NNTNTTTNTN
TT...

result:

wrong answer you dead (test case 2)