#include <iostream>
#include <cstring>
using namespace std;
string answer;
void speedy()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int inside(long long n, long long x, long long y)
{
if (1 <= x && x <= n && 1 <= y && y <= n)
return 1;
return 0;
}
int main()
{
speedy();
long long n, x0, y0, step, left, right;
int pp;
cin >> n >> x0 >> y0;
///find xL
step = 1;
long long xL_out = x0 - step, xL_in = x0;
pp = 0;
while (pp == 0)
{
if (inside(n, xL_out, y0) == 0)
pp = 1;
else
{
cout << "examine " << xL_out << ' ' << y0 << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
{
xL_in = xL_out;
step = step * 2;
xL_out = xL_out - step;
}
}
}
left = xL_out, right = xL_in;
long long xL;
while (left <= right)
{
long long mid = (left + right) / 2;
if (inside(n, mid, y0) == 0)
left = mid + 1;
else
{
cout << "examine " << mid << ' ' << y0 << '\n' << flush;
cin >> answer;
if (answer == "false")
left = mid + 1;
else
{
right = mid - 1;
xL = mid;
}
}
}
///find xR
step = 1;
long long xR_out = x0 + step, xR_in = x0;
pp = 0;
while (pp == 0)
{
if (inside(n, xR_out, y0) == 0)
pp = 1;
else
{
cout << "examine " << xR_out << ' ' << y0 << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
{
xR_in = xR_out;
step = step * 2;
xR_out = xR_out + step;
}
}
}
left = xR_in, right = xR_out;
long long xR;
while (left <= right)
{
long long mid = (left + right) / 2;
if (inside(n, mid, y0) == 0)
right = mid - 1;
else
{
cout << "examine " << mid << ' ' << y0 << '\n' << flush;
cin >> answer;
if (answer == "false")
right = mid - 1;
else
{
left = mid + 1;
xR = mid;
}
}
}
///find yU
step = 1;
long long yU_out = y0 + step, yU_in = y0;
pp = 0;
while (pp == 0)
{
if (inside(n, x0, yU_out) == 0)
pp = 1;
else
{
cout << "examine " << x0 << ' ' << yU_out << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
{
yU_in = yU_out;
step = step * 2;
yU_out = yU_out + step;
}
}
}
left = yU_in, right = yU_out;
long long yU;
while (left <= right)
{
long long mid = (left + right) / 2;
if (inside(n, x0, mid) == 0)
right = mid - 1;
else
{
cout << "examine " << x0 << ' ' << mid << '\n' << flush;
cin >> answer;
if (answer == "false")
right = mid - 1;
else
{
left = mid + 1;
yU = mid;
}
}
}
///find m, xC, yC
long long m = xR - xL + 1, xC = xL + m / 2, yC = yU - m / 2;
///find center
long long goL = 0;
pp = 0;
while (pp == 0)
{
if (inside(n, xC - 2 * m * (goL + 1), yC) == 0)
pp = 1;
else
{
cout << "examine " << xC - 2 * m * (goL + 1) << ' ' << yC << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
goL++;
}
}
long long goR = 0;
pp = 0;
while (pp == 0)
{
if (inside(n, xC + 2 * m * (goR + 1), yC) == 0)
pp = 1;
else
{
cout << "examine " << xC + 2 * m * (goR + 1) << ' ' << yC << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
goR++;
}
}
long long goD = 0;
pp = 0;
while (pp == 0)
{
if (inside(n, xC, yC - 2 * m * (goD + 1)) == 0)
pp = 1;
else
{
cout << "examine " << xC << ' ' << yC - 2 * m * (goD + 1) << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
goD++;
}
}
long long goU = 0;
pp = 0;
while (pp == 0)
{
if (inside(n, xC, yC + 2 * m * (goU + 1)) == 0)
pp = 1;
else
{
cout << "examine " << xC << ' ' << yC + 2 * m * (goU + 1) << '\n' << flush;
cin >> answer;
if (answer == "false")
pp = 1;
else
goU++;
}
}
cout << "solution " << xC + goR * m - goL * m << ' ' << yC + goU * m - goD * m << '\n' << flush;
return 0;
}
Compilation message
aliens.cpp: In function 'int main()':
aliens.cpp:150:49: warning: 'yU' may be used uninitialized in this function [-Wmaybe-uninitialized]
150 | long long m = xR - xL + 1, xC = xL + m / 2, yC = yU - m / 2;
| ^~
aliens.cpp:150:22: warning: 'xR' may be used uninitialized in this function [-Wmaybe-uninitialized]
150 | long long m = xR - xL + 1, xC = xL + m / 2, yC = yU - m / 2;
| ~~~^~~~
aliens.cpp:150:32: warning: 'xL' may be used uninitialized in this function [-Wmaybe-uninitialized]
150 | long long m = xR - xL + 1, xC = xL + m / 2, yC = yU - m / 2;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |