#include <stdio.h>
int query(long long x, long long y) {
static char s[8];
printf("examine %lld %lld\n", x, y), fflush(stdout);
scanf("%s", s);
return s[0] == 't';
}
int main() {
long long n, x, y, di, dj, lower, upper, k, s, x_, y_;
scanf("%lld%lld%lld", &n, &x, &y);
lower = 0, upper = 1;
while (x - upper >= 1 && query(x - upper, y))
lower = upper, upper *= 2;
while (upper - lower > 1) {
k = (lower + upper) / 2;
if (x - k >= 1 && query(x - k, y))
lower = k;
else
upper = k;
}
x_ = lower;
lower = 0, upper = 1;
while (x + upper <= n && query(x + upper, y))
lower = upper, upper *= 2;
while (upper - lower > 1) {
k = (lower + upper) / 2;
if (x + k <= n && query(x + k, y))
lower = k;
else
upper = k;
}
s = x_ + 1 + lower;
lower = 0, upper = 1;
while (y - upper >= 1 && query(x, y - upper))
lower = upper, upper *= 2;
while (upper - lower > 1) {
k = (lower + upper) / 2;
if (y - k >= 1 && query(x, y - k))
lower = k;
else
upper = k;
}
y_ = lower;
x += s / 2 - x_, y += s / 2 - y_;
x_ = y_ = 0;
for (di = -4; di <= 4; di++)
for (dj = -4; dj <= 4; dj++)
if ((di + dj) % 2 == 0) {
long long x1 = x + s * di, y1 = y + s * dj;
if (x1 >= 1 && x1 <= n && y1 >= 1 && y1 <= n && query(x1, y1))
x_ += x1, y_ += y1;
}
x_ /= 13, y_ /= 13;
printf("solution %lld %lld\n", x_, y_);
return 0;
}
Compilation message
aliens.c: In function 'query':
aliens.c:7:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
7 | scanf("%s", s);
| ^~~~~~~~~~~~~~
aliens.c: In function 'main':
aliens.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%lld%lld%lld", &n, &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 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 |
2 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 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 |
2 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 |
3 ms |
200 KB |
Output is correct |
3 |
Correct |
3 ms |
200 KB |
Output is correct |