#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, x0, y0;
cin >> n >> x0 >> y0;
x0--, y0--;
auto ask = [&](long long x, long long y) {
if (max(x, y) >= n || min(x, y) < 0) {
return false;
}
cout << "examine " << x + 1 << " " << y + 1 << endl;
string s;
cin >> s;
return (s == "true");
};
long long r;
{
long long t = 2;
while (ask(x0 + t - 1, y0)) {
t <<= 1;
}
long long lo = x0;
long long hi = x0 + t - 1;
while (hi - lo > 1) {
long long mid = (hi + lo) / 2;
if (ask(mid, y0)) {
lo = mid;
} else {
hi = mid;
}
}
r = lo;
}
long long l;
{
long long t = 2;
while (ask(x0 - t + 1, y0)) {
t <<= 1;
}
long long lo = x0 - t + 1;
long long hi = x0;
while (hi - lo > 1) {
long long mid = (hi + lo) / 2;
if (ask(mid, y0)) {
hi = mid;
} else {
lo = mid;
}
}
l = hi;
}
x0 = (l + r) / 2;
long long m = r - l + 1;
{
long long lo = y0;
long long hi = y0 + m;
while (hi - lo > 1) {
long long mid = (hi + lo) / 2;
if (ask(x0, mid)) {
lo = mid;
} else {
hi = mid;
}
}
y0 = lo - m / 2;
}
if (ask(x0 + 4 * m, y0)) {
x0 += 2 * m;
} else if (ask(x0 - 4 * m, y0)) {
x0 -= 2 * m;
} else {
int a = ask(x0 + 2 * m, y0);
int b = ask(x0 - 2 * m, y0);
if (a && !b) {
x0 += m;
} else if (!a && b) {
x0 -= m;
}
}
if (ask(x0, y0 + 3 * m)) {
y0 += m;
} else if (ask(x0, y0 - 3 * m)) {
y0 -= m;
} else {
int a = ask(x0, y0 + 2 * m);
int b = ask(x0, y0 - 2 * m);
if (a && !b) {
y0 += 2 * m;
} else if (!a && b) {
y0 -= 2 * m;
}
}
cout << "solution " << x0 + 1 << " " << y0 + 1 << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |