#include <bits/stdc++.h>
using namespace std;
#define x0 xO
#define y0 yO
int n,x0,y0;
int Ask(int x, int y)
{
if(x>n || y>n || x<0 || y<0) return 0;
printf("examine %i %i\n",x,y);
fflush(stdout);
char o[20];
scanf("%s",o);
if(o[0]=='t') return 1;
else return 0;
}
void Answer(int x, int y)
{
printf("solution %i %i\n",x,y);
fflush(stdout);
}
int main()
{
scanf("%i %i %i",&n,&x0,&y0);
int hi,lo,mi;
hi=n-x0,lo=0;
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
{
if(Ask(x0+mi,y0)) lo=mi;
else hi=mi-1;
}
x0+=lo;
hi=y0,lo=0;
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
{
if(Ask(x0,y0-mi)) lo=mi;
else hi=mi-1;
}
y0-=lo;
hi=min(n-x0,y0),lo=0;
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
{
if(Ask(x0+mi,y0-mi)) lo=mi;
else hi=mi-1;
}
x0+=lo;y0-=lo;
hi=min(x0,n-y0),lo=0;
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
{
if(Ask(x0-mi,y0+mi)) lo=mi;
else hi=mi-1;
}
int x1=x0-lo,y1=y0+lo;
int len=lo+1;
if(len%5==0 && !Ask(x0,y0-len/5))
{
int x2=x0-(len-1)/2,y2=y0+(len-1)/2;
Answer(x2,y2);
}
else if(len%3==0 && !Ask(x0,y0-len/3))
{
int m=len/3;
len=m*5;
if(Ask(x0+2*m,y0))
{
int x2=x0-(m-1)/2,y2=y0+(len-1)/2;
Answer(x2,y2);
}
else
{
int x2=x0-(len-1)/2,y2=y0+(m-1)/2;
Answer(x2,y2);
}
}
else
{
int m=len;
len=m*5;
if(Ask(x0+2*m,y0))
{
int x2=x0-m+1+(len-1)/2,y2=y0+(len-1)/2;
Answer(x2,y2);
}
else
{
int x2=x0-(len-1)/2,y2=y0+m-1-(len-1)/2;
Answer(x2,y2);
}
}
return 0;
}
Compilation message
aliens.cpp: In function 'int main()':
aliens.cpp:26:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:26:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:33:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:33:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:40:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:40:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:47:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:47:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
~~~~~^~
aliens.cpp:52:6: warning: unused variable 'x1' [-Wunused-variable]
int x1=x0-lo,y1=y0+lo;
^~
aliens.cpp:52:15: warning: unused variable 'y1' [-Wunused-variable]
int x1=x0-lo,y1=y0+lo;
^~
aliens.cpp: In function 'int Ask(int, int)':
aliens.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",o);
~~~~~^~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i %i %i",&n,&x0,&y0);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
404 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
412 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |