QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227923#6739. TeleportwangqingxianWA 0ms3604kbC++141.4kb2023-10-28 09:23:112023-10-28 09:23:11

Judging History

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

  • [2023-10-28 09:23:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2023-10-28 09:23:11]
  • 提交

answer

#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<queue>
#include<iomanip>
#include<stdlib.h>
#include<set>
#include<cmath>
#define lowbit(i) (i&-i)
using namespace std;
const int N=2e2+10,inf=0x7fffffff,mod=1e9+7;
int n,k;
struct giao{
    int x;
    int y;
    int step;
};
queue<giao> que;
bool book[N][N];
int nx[4]={0,0,1,-1};
int ny[4]={1,-1,0,0};
signed main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++){
        char ch;cin>>ch;
        if(ch=='*') book[i][j]=1;
    }
    que.push({1,1,0});
    book[1][1]=1;
    while(!que.empty()){
        giao hd=que.front();
        que.pop();
        if(hd.x==n&&hd.y==n){
            cout<<hd.step+1<<endl;
            return 0;
        }
        for(int i=0;i<4;i++){
            int tx=hd.x+nx[i],ty=hd.y+ny[i];
            if(tx<1||ty<1||tx>n||ty>n) continue;
            if(book[tx][ty]) continue;
            book[tx][ty]=1;
            que.push({tx,ty,hd.step+1});
        }
        int lx=hd.x,ly=hd.y;
        for(int i=1;i<=k;i++){
            int tx=ly+1,ty=lx;
            lx=tx;ly=ty;
            if(tx<1||ty<1||tx>n||ty>n) break;
            if(book[tx][ty]) continue;
            book[tx][ty]=1;
            que.push({tx,ty,hd.step+1});
        }
    }
    cout<<-1<<endl;
    return 0;
}
/*
3 3
.*.
.*.
...
 
 */

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

3 2
.*.
.*.
...

output:

4

result:

wrong answer 1st numbers differ - expected: '3', found: '4'