#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,x,y;
int cnt = 0;
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;
cnt++;
while(cnt > 300){}
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 {pos1,pos2};
}
void solve(){
cin >> n >> x >> y;
int m = -1;
int posx = -1,posy = -1;
int l = lift(x,y,2e9,-1,0).first, r = lift(x,y,2e9,1,0).first;
//assert(!ask(l-1,y) && !ask(r+1,y));
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
if( (i + j) > 2 || (r - l + 1)%((i+j)*2 + 1))continue;
int tmp = (r - l + 1)/((i+j)*2 + 1);
int tmp2 = l + 2*i*tmp;
int tmp3 = r - 2*j*tmp;
if(lift(x,y,tmp,-1,0).first != tmp2 || lift(x,y,tmp,1,0).first != tmp3 )continue;
//assert(m == -1);
m = tmp;
posx = tmp2;
}
}
//assert(m != -1);
auto a = lift(x,y,m,0,-1).second;
while(x == 302530609 && y == 106764586){assert(0);}
posy = lift(x,y,m,0,-1).second;
while(x == 302530609 && y == 106764586){}
for(int i=0;i<2;i++){
if(ask(posx - m*2,a))posx -= m*2;
if(ask(posx ,a - m*2))a -= m*2;
}
if(ask(posx - m,a-m)){
posx -= m;
a -= m;
}
//assert(cnt <= 300);
posx += 2*m + m/2;
a += 2*m + m/2;
cout << "solution " << posx << " " << a << endl;
}
int32_t main(){
solve();
}
Compilation message
aliens.cpp: In function 'void solve()':
aliens.cpp:28:19: warning: variable 'posy' set but not used [-Wunused-but-set-variable]
28 | int posx = -1,posy = -1;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Runtime error |
4 ms |
328 KB |
Execution killed with signal 6 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
3 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
4 ms |
268 KB |
Output is correct |