#include <bits/stdc++.h>
using namespace std;
int n,x,y;
bool ask(int pos1,int pos2){
if(min(pos1,pos2) < 1 || max(pos1,pos2) > n)return 0;
cout << "examine " << pos1 << " " << pos2 << endl;
string s;
cin >> s;
return s == "true";
}
pair<int,int> lift(int pos1,int pos2,int m,int dir1,int dir2){
for(int i=30;i>=0;i--){
if((1<<i) <= m && ask(pos1 + dir1*(1<<i),pos2 + dir2*(1<<i))){
pos1 += dir1*(1<<i);
pos2 += dir2*(1<<i);
m -= (1<<i);
}
}
return make_pair(pos1,pos2);
}
pair<int,int> find(int pos1,int pos2,int dir1,int dir2){
for(int i = 1;;i*=2){
if(!ask(pos1 + dir1*i,pos2+dir2*i)){
return lift(pos1,pos2,i,dir1,dir2);
}
}
}
int main(){
cin >> n >> x >> y;
int m = -1;
int posx = -1,posy = -1;
int l = find(x,y,-1,0).first, r = find(x,y,1,0).first;
m = r-l+1;
posx = l;
posy = lift(x,y,m,0,-1).second;
for(int i=0;i<2;i++){
if(ask(posx - m*2,posy))posx -= m*2;
if(ask(posx ,posy - m*2))posy -= m*2;
}
if(ask(posx - m,posy-m)){
posx -= m;
posy -= m;
}
posx += 2*m + m/2;
posy += 2*m + m/2;
cout << "solution " << posx << " " << posy << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |