#include <bits/stdc++.h>
using namespace std;
int n,m,x,y;
int query (int x, int y){
cout<<"examine "<<x<<" "<<y<<endl;
string ans;
cin>>ans;
if (ans == "true")
return 1;
return 0;
}
int main (){
cin>>n>>x>>y;
/// vreau sa determin coordonatele coltului patratului mic din care face parte x,y
int st = 0, dr = n - y, sol = 0;
while (st <= dr){
int mid = (st+dr)>>1;
if (query(x,y+mid) == 0) /// clar ma aflu prea sus
dr = mid-1;
else {
/// testez mijlocul
if (query (x,(2*y+mid)/2) == 0) /// tot prea sus
dr = mid-1;
else {
int mid2 = (2*y+mid)/2;
if (query(x,(y+mid2)/2) == 0)
dr = mid-1;
else {
sol = mid;
st = mid+1;
}}}}
y += sol;
st = 0, dr = x-1, sol = 0;
while (st <= dr){
int mid = (st+dr)>>1;
if (query (x-mid,y) == 0)
dr = mid-1;
else {
if (query((2*x-mid)/2,y) == 0)
dr = mid-1;
else {
int mid2 = (2*x-mid)/2;
if (query((x+mid2)/2,y) == 0)
dr = mid-1;
else {
sol = mid;
st = mid+1;
}}}}
x -= sol;
/// acum determin M ul la fel
st = 0, dr = y-1, sol = 0;
while (st <= dr){
int mid = (st+dr)>>1;
if (query(x,y-mid) == 0) /// clar ma aflu prea sus
dr = mid-1;
else {
/// testez mijlocul
if (query (x,(2*y-mid)/2) == 0) /// tot prea sus
dr = mid-1;
else {
int mid2 = (2*y-mid)/2;
if (query(x,(y+mid2)/2) == 0)
dr = mid-1;
else {
sol = mid;
st = mid+1;
}}}}
m = sol + 1;
/// stanga sus
while (x - m >= 1 && y + m <= n){
if (query (x-m,y+m))
x -= m, y += m;
else break;
}
/// stanga
while (x - 2*m >= 1){
if (query (x-2*m,y))
x -= 2*m;
else break;
}
/// sus
while (y + 2*m <= n){
if (query (x,y+2*m))
y += 2*m;
else break;
}
cout<<"solution "<<x + 2*m + m/2<<" "<<y - 2*m - m/2;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Incorrect |
7 ms |
256 KB |
too many queries |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Incorrect |
8 ms |
256 KB |
too many queries |
3 |
Halted |
0 ms |
0 KB |
- |