QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#538057 | #2615. Surround the Cat | Lavine# | TL | 0ms | 0kb | C++14 | 1.9kb | 2024-08-30 22:16:17 | 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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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