QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663264#4432. Jungle TrailYaeMik0WA 8148ms140396kbC++232.3kb2024-10-21 14:29:112024-10-21 14:29:12

Judging History

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

  • [2024-10-21 14:29:12]
  • 评测
  • 测评结果:WA
  • 用时:8148ms
  • 内存:140396kb
  • [2024-10-21 14:29:11]
  • 提交

answer

#include<bits/stdc++.h>
#define INF 2147483647LL
#define int long long
#define MAXN 300005
#define mod 1000000007
#define PI 3.14
#define eps 1e-10
#define pa pair<int,int>
#define ms(a,x) memset(a,x,sizeof(a))
#define mc(ar1,ar2) memcpy(ar1,ar2,sizeof(ar2))
#define mkp(a,b) make_pair(a,b)
#define ls (p<<1)
#define rs (p<<1|1)
#define fn(i,st,ed) for(int i=st;i<=ed;++i)
#define fd(i,st,ed) for(int i=st;i>=ed;--i)
#define fg(i,x,head,e) for(int i=head[x];~i;i=e[i].nxt)
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
struct node{
    int x,y;
    string stp;
};
string mp[4050];
int vis[4050][4050],nowr[4050],nowc[4050];
int dx[5]={1,0},dy[5]={0,1};
string ans;
void solve(){
    ms(vis,0);ms(nowr,0);ms(nowc,0);
    ans="";
    int n,m,flg=0;cin>>n>>m;
    fn(i,0,n-1)cin>>mp[i];
    queue<node>q;vis[0][0]=1;
    q.push({0,0,""});
    while(!q.empty()){
        node now=q.front();q.pop(); 
        int nx=now.x,ny=now.y;
        string stp=now.stp;
        //cerr<<nx<<' '<<ny<<endl;
        //if(nx<0||ny<0||mp[nx][ny]=='#'||nx>n-1||ny>m-1||vis[nx][ny])continue;vis[nx][ny]=1;
        if(nx==n-1&&ny==m-1){
            ans=stp,flg=1;
            break;
        }
        fn(i,0,1){
            int tx=nx+dx[i],ty=ny+dy[i];
            if(tx<0||ty<0||mp[tx][ty]=='#'||vis[tx][ty]||tx>n-1||ty>m-1)continue;
            vis[tx][ty]=1;
            if(!i)stp+='D';
            else stp+='P';
            q.push({tx,ty,stp});
        }
    }
    if(!flg){cout<<"NIE\n";return;}
    int nx=0,ny=0;
    string nr="",nc="";
    if(mp[0][0]=='@'){nr+='T',nc+='N';nowr[0]^=1;}
    else nr+='N',nc+='N';
    fn(i,0,n+m-3){
        if(ans[i]=='D')nx++;
        else ny++;
        if((mp[nx][ny]=='@'&&(!(nowr[nx]^nowc[ny])))||(mp[nx][ny]=='O'&&(nowr[nx]^nowc[ny]))){
            if(ans[i]=='D')nr+='T',nowr[nx]^=1;
            else nc+='T',nowc[ny]^=1;
        }
        else {
            if(ans[i]=='D')nr+='N';
            else nc+='N';
        }
    }
    if(nr.size()!=n){
        fn(i,0,n-1)cout<<mp[i];
    }
    cout<<"TAK\n"<<nr<<"\n"<<nc<<"\n"<<ans<<'\n';
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while(T--){solve();}
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 8148ms
memory: 140396kb

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
TAK
TT
NN
PD
TAK
TN
NT
PD
TAK
TN
NN
DP
TAK
NT
NT
DP
NIE
TAK
TN
NT
DP
TAK
TN
NN
DP
TAK
NN
NN
DP
NIE
TAK
TTNNTTTTNT
NNTTNNTTNN
PDDDPPDDDDPPDDPPPP
OO@#@O#@##@#@#O#O.O#@O@#O#@O@#@@O@O#O@OOO@O#O@#O@@@O#@@@O.O@#@@@OO@O#O@@#O@OO@O#O@@@O@OO@OOOO@@#O@@OTAK
NTT...

result:

wrong answer unknown result OO@#@O#@##@#@#O#O.O#@O@#O#@O@#@@O@O#O@OOO@O#O@#O@@@O#@@@O.O@#@@@OO@O#O@@#O@OO@O#O@@@O@OO@OOOO@@#O@@OTAK (test case 14)