#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
ll query(ll x,ll y)
{
if(x<=0||y<=0||x>n||y>n) return 0;
cout << "examine " << x << " " << y << endl;
string s;
cin >> s;
return (s[0]=='t');
}
int main()
{
ll x,y,L,R,l,r,dis,m;
cin >> n >> x >> y;
l=x,r=n+1;
while(l<r)
{
ll mid=l+r>>1;
if(query(mid,y)==1) l=mid+1;
else r=mid;
}
R=l,l=0,r=x;
while(l<r)
{
ll mid=(l+r)/2+1;
if(query(mid,y)==0) l=mid;
else r=mid-1;
}
L=l,dis=R-L-1;
//cout << "part2: " << L << " " << R << endl;
ll c=L+R>>1,cx,cy;
if(query(c,y)==0) m=dis/3;
else if(dis%5==0)
if(query(c+dis/5,y)==0) m=dis/5;
else m=dis;
//cout << "part3: " << m << endl;
l=x,r=x+m;
while(l<r)
{
ll mid=l+r>>1;
if(query(mid,y)==1) l=mid+1;
else r=mid;
}
R=l,l=x-m,r=x;
while(l<r)
{
ll mid=(l+r)/2+1;
if(query(mid,y)==0) l=mid;
else r=mid-1;
}
L=l,cx=L+R>>1;
//cout << "part4: " << cx << endl;
l=y,r=y+m;
while(l<r)
{
ll mid=l+r>>1;
if(query(cx,mid)==1) l=mid+1;
else r=mid;
}
R=l,l=y-m,r=y;
while(l<r)
{
ll mid=(l+r)/2+1;
if(query(cx,mid)==0) l=mid;
else r=mid-1;
}
L=l,cy=L+R>>1;
//cout << "part5: " << cy << endl;
l=query(cx,cy+2*m)+query(cx,cy+4*m);
r=query(cx,cy-2*m)+query(cx,cy-4*m);
if(l+r==2)
if(l==2) cy+=2*m;
else if(r==2) cy-=2*m;
else;
else
if(l==1) cy+=m,cx+=m;
else cy-=m,cx+=m;
c=query(cx+2*m,cy)+query(cx+4*m,cy);
if(c==2) cx+=2*m;
else if(c==0) cx-=2*m;
cout << "solution " << cx << " " << cy << endl;
}
Compilation message
aliens.cpp: In function 'int main()':
aliens.cpp:34:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll mid=l+r>>1;
~^~
aliens.cpp:47:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll c=L+R>>1,cx,cy;
~^~
aliens.cpp:49:9: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
else if(dis%5==0)
^
aliens.cpp:56:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll mid=l+r>>1;
~^~
aliens.cpp:67:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
L=l,cx=L+R>>1;
~^~
aliens.cpp:72:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll mid=l+r>>1;
~^~
aliens.cpp:83:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
L=l,cy=L+R>>1;
~^~
aliens.cpp:85:17: warning: 'm' may be used uninitialized in this function [-Wmaybe-uninitialized]
l=query(cx,cy+2*m)+query(cx,cy+4*m);
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Expected int32, but "-140731005493310" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Expected int32, but "-140736339782154" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 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 |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
384 KB |
Expected int32, but "-140720849176775" found |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
284 KB |
Output is correct |
2 |
Correct |
2 ms |
276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
284 KB |
Output is correct |
3 |
Correct |
4 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 |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
304 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |