#include<bits/stdc++.h>
using namespace std;
bool examine(long long a, long long b)
{
printf("examine %lld %lld\n",a,b);
fflush(stdout);
string ret;
scanf(" %s",ret);
return (ret[0] == 't') ? true : false;
}
void solution(long long a, long long b)
{
printf("solution %lld %lld\n",a,b);
fflush(stdout);
}
int main()
{
long long n, x, y, l, r, L, R, T, B, sz;
scanf(" %lld %lld %lld",&n,&x,&y);
//right
l = x, r = n;
while(l != r)
{
long long mid = (l+r+1)>>1ll;
if(!examine(mid, y)) r = mid-1;
else if(!examine((l+mid)>>1ll, y)) r = mid-1;
else if(!examine((l+((l+mid)>>1ll))>>1ll, y)) r = mid-1;
else l = mid;
}
R = l;
//left
l = 1, r = x;
while(l != r)
{
long long mid = (l+r)>>1ll;
if(!examine(mid, y)) l = mid+1;
else if(!examine((mid+r)>>1ll, y)) l = mid+1;
else if(!examine((((mid+r)>>1ll)+r)>>1ll, y)) l = mid+1;
else r = mid;
}
L = l;
//top
l = y, r = n;
while(l != r)
{
long long mid = (l+r+1)>>1ll;
if(!examine(x, mid)) r = mid-1;
else if(!examine(x, (l+mid)>>1ll)) r = mid-1;
else if(!examine(x, (l+((l+mid)>>1ll))>>1ll)) r = mid-1;
else l = mid;
}
T = l;
sz = R-L+1;
B = T-sz+1;
long long mx = (L+R)>>1ll, my = (B+T)>>1ll;
int tl = 0, tr = 0, bl = 0, br = 0;
for(int i=1 ; i<=4 ; i++)
{
if(mx - i*sz >= 1 && my + i*sz <= n && examine(mx-i*sz, my+i*sz)) tl++;
if(mx + i*sz <= n && my + i*sz <= n && examine(mx+i*sz, my+i*sz)) tr++;
if(mx - i*sz >= 1 && my - i*sz >= 1 && examine(mx-i*sz, my-i*sz)) bl++;
if(mx + i*sz <= n && my - i*sz >= 1 && examine(mx+i*sz, my-i*sz)) br++;
}
if(tl == 0)
{
if(tr == 4) solution(mx+2*sz, my+2*sz);
else if(bl == 4) solution(mx-2*sz, my-2*sz);
else if(br == 4) solution(mx+2*sz, my-2*sz);
else if(tr == 2) solution(mx+sz, my);
else solution(mx, my-sz);
}
else if(tl == 1)
{
if(tr == 3) solution(mx+sz, my+sz);
else if(bl == 3) solution(mx-sz, my-sz);
else solution(mx+sz, my-sz);
}
else if(tl == 2)
{
if(bl + br == 0) solution(mx, my+sz);
else if(bl + br == 2) solution(mx-sz, my);
else solution(mx, my);
}
else if(tl == 3) solution(mx-sz, my+sz);
else solution(mx-2*sz, my+2*sz);
return 0;
}
Compilation message
aliens.cpp: In function 'bool examine(long long int, long long int)':
aliens.cpp:9:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' [-Wformat=]
scanf(" %s",ret);
^
aliens.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %s",ret);
~~~~~^~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %lld %lld %lld",&n,&x,&y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
380 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |