QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#538078#2615. Surround the CatLavine#WA 1ms3940kbC++141.9kb2024-08-30 22:59:402024-08-30 22:59:41

Judging History

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

  • [2024-08-30 22:59:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3940kb
  • [2024-08-30 22:59:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=105,k1[6][2]={1,1,1,0,0,-1,-1,-1,-1,0,0,1},k2[6][2]={1,2,2,1,1,-1,-1,-2,-2,-1,-1,1},P=50;
int v[N][N],cx,cy,g[N][N];
void Pt(int x,int y){
    printf("%d %d\n",x,y);
    g[x+P][y+P]=1;
    fflush(stdout);
}
void init(){
    for(int i=0;i<=9;++i)v[9+P][i+P]=v[i+P][9+P]=1;
    for(int i=0;i<=9;++i)v[P-i][P+9-i]=v[P-9][P-i]=1;
    for(int i=0;i<=9;++i)v[P-i][P-9]=v[P+i][P-9+i]=1;
    scanf("%d %d",&cx,&cy);
    Pt(9,1);
    scanf("%d %d",&cx,&cy);
    Pt(8,9);
    scanf("%d %d",&cx,&cy);
    Pt(-1,8);
    scanf("%d %d",&cx,&cy);
    Pt(-9,-1);
    scanf("%d %d",&cx,&cy);
    Pt(-8,-9);
    scanf("%d %d",&cx,&cy);
    Pt(1,-8);
    scanf("%d %d",&cx,&cy);
}
bool ck(int x,int y){
    return v[x+P][y+P]&&!g[x+P][y+P];
}
void Rd(){
    bool fl=1;
    for(int i=0;i<6;++i){
        int x=cx+k1[i][0],y=cy+k1[i][1];
        if(!g[x+P][y+P]){
            fl=0;
            break;
        }
    }
    if(fl){
        // puts("win");
        exit(0);
    }
    scanf("%d %d",&cx,&cy);
    while(g[cx+P][cy+P]){
        // puts("cat can't walk here.");
        scanf("%d %d",&cx,&cy);
    }
}
vector<pair<int,int> >nb1,nb2;
int main(){
    init();
    while(1){
        nb1.clear(),nb2.clear();
        for(int i=0;i<6;++i){
            if(ck(cx+k1[i][0],cy+k1[i][1]))nb1.push_back(make_pair(cx+k1[i][0],cy+k1[i][1]));
            if(ck(cx+k2[i][0],cy+k2[i][1]))nb2.push_back(make_pair(cx+k2[i][0],cy+k2[i][1]));
        }
        
        if(!nb1.empty()){
            for(auto t:nb1)Pt(t.first,t.second);
        }else if(!nb2.empty()){
            for(auto t:nb2)Pt(t.first,t.second);
        }else {
            for(int i=0;i<6;++i){
                int x=cx+k1[i][0],y=cy+k1[i][1];
                if(!g[x+P][y+P]){
                    Pt(x,y);
                    break;
                }
            }
        }
        Rd();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3832kb

input:

0 0
1 0
2 1
3 2
4 3
5 4
6 5
7 5
7 4
7 3
7 4
7 3
7 2
7 1
7 2
7 1
7 2
7 3
7 4
7 5
7 4
7 5
6 5
6 6
6 7
5 7
6 7
5 7
6 7
5 7
4 7
5 7
4 7
5 7
4 7
3 7
4 7
3 7
2 7
3 7
2 7
1 7
2 7
1 7
2 7
1 7
0 7
1 7
0 7
1 7
0 7
-1 6
0 7
0 8
0 7
0 8

output:

9 1
8 9
-1 8
-9 -1
-8 -9
1 -8
7 6
9 6
9 5
9 4
8 5
8 4
9 3
9 2
8 3
8 2
7 1
7 2
7 3
8 6
6 3
7 4
7 5
7 7
7 9
6 9
7 8
6 8
6 6
6 7
5 9
5 6
5 8
4 6
5 7
4 9
3 6
4 8
3 9
4 7
3 8
2 9
3 7
2 8
2 6
2 7
1 9
1 6
1 8
0 6
1 7
-2 7
-1 6
0 9
-1 7
0 7

result:

ok There is no valid neighbouring location.

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3940kb

input:

0 0
-1 -1
-2 -2
-3 -3
-4 -4
-5 -5
-6 -6
-7 -7
-7 -6
-7 -5
-7 -6
-7 -7
-7 -6
-7 -5
-7 -4
-7 -5
-7 -4
-7 -3
-7 -2
-7 -3
-7 -4
-7 -3
-7 -2
-7 -1
-7 -2
-7 -1
-7 -2
-7 -1
-7 0
-7 -1
-7 0
-7 -1
-7 0
-7 1
-7 0
-7 1
-7 0
-7 1

output:

9 1
8 9
-1 8
-9 -1
-8 -9
1 -8
-5 -5
-9 -8
-9 -7
-9 -6
-6 -5
-6 -6
-7 -7
-6 -4
-9 -5
-7 -6
-6 -3
-9 -4
-9 -3
-6 -2
-7 -5
-7 -4
-6 -1
-9 -2
-7 -3
-6 0
-8 -3
-7 -2
-8 1
-8 -2
-6 1
-8 -1
-7 -1
-7 2
-8 0
-6 3
-9 0
-7 1

result:

wrong answer -7 1 is the location the cat currently locates in!