#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
auto q=[&](ll x,ll y)->bool
{
if(!(1<=x&&x<=n&&1<=y&&y<=n)) return 0;
cout << "examine " << x << " " << y << endl;
string s;
cin >> s;
return (s=="true");
};
auto bins=[&](ll x,ll y,ll kx,ll ky,ll bad)->int
{
ll l=0,r=bad;
while(l<r-1)
{
ll m=(l+r)/2;
if(q(x+kx*m,y+ky*m)) l=m;
else r=m;
}
return l;
};
ll x,y;
cin >> x >> y;
ll p=1;
while(q(x+p-1,y)) p*=2;
ll rx=x+bins(x,y,1,0,min(n+1,x+p-1)-x);
p=1;
while(q(x-p+1,y)) p*=2;
ll lx=x-bins(x,y,-1,0,x-max(ll(0),x-p+1));
ll m=rx-lx+1;
ll ly=y-bins(x,y,0,-1,y-max(ll(0),y-m));
ll ry=ly+m-1;
vector<string> s(5,string(5,'0'));
for(int i=0;i<5;i++) for(int j=0;j<5;j++) if(((i+j)%2)==0) s[i][j]='1';
auto one=[&](int r,int c)->bool{return (0<=r&&r<5&&0<=c&&c<5&&s[r][c]=='1');};
vector<array<int,2>> queries;
for(int i=0;i<5;i++) for(int j=0;j<5;j++) if(one(i,j)&&!(i==2&&j==2)) queries.push_back({i-2,j-2});
map<vector<bool>,array<int,2>> pos;
int sz=12;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(!one(i,j)) continue;
vector<bool> v(sz,0);
for(int k=0;k<sz;k++) v[k]=one(i+queries[k][0],j+queries[k][1]);
pos[v]={2-i,2-j};
}
}
vector<bool> v(sz,0);
for(int k=0;k<sz;k++) v[k]=q(x+queries[k][0]*m,y+queries[k][1]*m);
ll mx=(lx+rx)/2;
ll my=(ly+ry)/2;
auto [dx,dy]=pos[v];
cout << "solution " << mx+m*dx << " " << my+m*dy << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |