QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#41334#4376. Dragon slayer01shijian#WA 719ms3920kbC++172.2kb2022-07-29 17:37:472022-07-29 17:37:50

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 17:37:50]
  • 评测
  • 测评结果:WA
  • 用时:719ms
  • 内存:3920kb
  • [2022-07-29 17:37:47]
  • 提交

answer

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

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

struct Node
{
    int x1,y1,x2,y2;
}wall[N];

bool bfs()
{
    queue<PII> q;
    memset(st,0,sizeof st);
    st[xs][ys] = 1;
    q.push({xs,ys});
    while(q.size())
    {
        auto t = q.front();
        q.pop();
        if(t.first==xt&&t.second==yt) return 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;
            if(st[nx][ny]) continue;
            int tx,ty;
            if(!dx[i]) tx = 3*nx - 1,ty = min(t.second,ny);
            else tx = min(t.first,nx)*3,ty = ny;
            if(g[tx][ty]) continue;
            st[nx][ny] = 1;
            q.push({nx,ny});
        }
    }
    return 0;
}

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);
        for(int i=1;i<=K;i++)
        {
            int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
            wall[i] = {x1,y1,x2,y2};
        }
        int ans = INT_MAX;
        for(int i=0;i<1<<K;i++)
        {
            memset(g,0,sizeof g);
            int cnt = 0;
            for(int j=0;j<K;j++)
                if(i>>j&1)
                {
                    cnt++;
                    int x1 = wall[j+1].x1,x2 = wall[j+1].x2,y1 = wall[j+1].y1,y2 = wall[j+1].y2;
                    if(x1==x2){
                        if(y1>=y2) swap(y1,y2);
                        for(int i=y1+1;i<=y2;i++)
                            g[3*x1][i] = 1;
                    }
                    else{
                        if(x1>=x2) swap(x1,x2);
                        for(int i=x1;i<=x2-1;i++)
                            g[3*i+1][y1] = 1;
                    }
                }
            if(bfs()) ans = min(K-cnt,ans);
        }
        printf("%d\n",ans);
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 719ms
memory: 3920kb

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:

0
1
0
0
2
0
0
0
1
0

result:

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