QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#538079 | #2615. Surround the Cat | Lavine | WA | 1ms | 3896kb | C++14 | 2.0kb | 2024-08-30 23:11:10 | 2024-08-30 23:11:10 |
Judging History
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);
break;
}
}else if(!nb2.empty()){
for(auto t:nb2){
Pt(t.first,t.second);
break;
}
}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();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3896kb
input:
0 0
output:
____9 1
result:
wrong answer format Expected integer, but "____9" found