QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#538057#2615. Surround the CatLavine#TL 0ms0kbC++141.9kb2024-08-30 22:16:172024-08-30 22:16:17

Judging History

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

  • [2024-08-30 22:16:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-30 22:16:17]
  • 提交

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;
}
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);
    fflush(stdout);
    scanf("%d %d",&cx,&cy);
    Pt(8,9);
    fflush(stdout);
    scanf("%d %d",&cx,&cy);
    Pt(-1,8);
    fflush(stdout);
    scanf("%d %d",&cx,&cy);
    Pt(-9,-1);
    fflush(stdout);
    scanf("%d %d",&cx,&cy);
    Pt(-8,-9);
    fflush(stdout);
    scanf("%d %d",&cx,&cy);
    Pt(-1,8);
    fflush(stdout);
    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][y]){
            fl=0;
            break;
        }
    }
    if(fl)exit(0);
    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][y]){
                    Pt(x,y);
                    break;
                }
            }
        }
        Rd();
    }
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

0 0
1 0
2 1
3 2
4 3
5 4
6 5

output:

9 1
8 9
-1 8
-9 -1
-8 -9
-1 8

result: