QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#41327#4376. Dragon slayeraitejiuWA 2ms3800kbC++2.8kb2022-07-29 16:44:582022-07-29 16:45:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-29 16:45:00]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3800kb
  • [2022-07-29 16:44:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
// typedef pari<int,PII> PIII;
const int N = 20;

int dist[N][N];
bool st[N][N],g[N<<1][N<<1];
int dx[4] = {1,-1,0,0},dy[4] = {0,0,1,-1};
int d1[4] = {0,-1,-1,-1},d2[4] = {-1,-1,0,-1};
int n,m,K,xs,ys,xt,yt;

void bfs()
{
    memset(dist,0x3f,sizeof dist);
    memset(st,0,sizeof st);
    dist[xs][ys] = 0;
    deque<PII> q;
    q.push_front({xs,ys});
    while(q.size())
    {
        auto t = q.front();
        q.pop_front();
        // cout<<t.first<<" "<<t.second<<endl;
        if(t.first==xt&&t.second==yt) return ;
        if(st[t.first][t.second]) continue;
        st[t.first][t.second] = 1;
        for(int i=0;i<4;i++)
        {
            int nx = t.first + dx[i],ny = t.second + dy[i];
            int w = 0;
            if(nx>n||nx<=0||ny>m||ny<=0) continue;
            int tx,ty;
            if(!dx[i]) tx = 2*nx - 1,ty = min(t.second,ny);
            else tx = min(t.first,nx)*2,ty = ny;
            if(g[tx][ty]) w = 1;
            // if(nx==3&&ny==2&&t.first==3&&t.second==1)
            // {
            //     cout<<dist[t.first][t.second]<<" "<<dist[nx][ny]<<" "<<w<<endl;
            //     cout<<tx<<" "<<ty<<endl;
            // }
            if(dist[nx][ny]>dist[t.first][t.second]+w)
            {
                // if(t.first==3&&t.second==1)
                // {
                //     cout<<nx<<" "<<ny<<endl;
                //     cout<<dist[t.first][t.second]<<endl;
                // }
                // if(nx==3&&ny==2) 
                // {
                //     cout<<w<<endl;
                //     cout<<t.first<<" "<<t.second<<" "<<dist[t.first][t.second]<<endl;
                //     cout<<dist[nx][ny]<<endl;
                // }
                dist[nx][ny] = dist[t.first][t.second] + w;
                if(!w) q.push_front({nx,ny});
                else q.push_back({nx,ny});
            }
        }
    }
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d",&n,&m,&K);
        scanf("%d%d%d%d",&xs,&ys,&xt,&yt);
        xs++,ys++,xt++,yt++;
        memset(g,0,sizeof g);
        while(K--)
        {
            int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
            if(x1==x2){
                if(y1>=y2) swap(y1,y2);
                for(int i=y1+1;i<=y2;i++)
                    g[2*x1][i] = 1;
            }
            else{
                if(x1>=x2) swap(x1,x2);
                for(int i=x1;i<=x2-1;i++)
                    g[2*i+1][y1] = 1;
            }
        }
        // for(int i=0;i<m;i++){
        //     for(int j=0;j<n;j++)
        //         cout<<g[j][i]<<" ";
        //     cout<<endl;
        // }
        bfs();
        printf("%d\n",dist[xt][yt]);
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3800kb

input:

10
4 4 4 0 2 3 3
0 2 4 2
1 3 1 0
2 4 2 1
3 1 3 4
3 2 2 0 0 2 1
0 1 3 1
1 0 1 2
3 2 2 0 0 2 1
2 1 2 2
1 0 1 1
15 15 15 3 12 4 1
8 0 8 15
1 11 15 11
1 1 1 15
3 1 3 15
0 10 14 10
14 1 14 14
8 1 8 15
1 5 14 5
0 15 14 15
0 4 14 4
0 2 15 2
11 0 11 15
4 1 4 15
1 11 15 11
1 12 14 12
15 15 15 8 5 14 0
0 12 1...

output:

2
2
0
5
3
6
1
4
1
0

result:

wrong answer 1st lines differ - expected: '1', found: '2'