이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
int query(long long i) {
int x;
printf("? %lld\n", i), fflush(stdout);
scanf("%d", &x);
return x;
}
int main() {
long long n, m, l, r, c;
int turn;
scanf("%lld", &n);
l = 0;
for (m = n - 1; m > 0; m /= 4)
l -= (m + 1) / 2;
l = 1 - l, r = l, m = n - 1, turn = 0;
query(r);
c = 1;
for (m = n - 1; m > 0; m /= 2, turn ^= 1)
if (turn == 0) {
if (query(l -= (m + 1) / 2))
r -= (m + 1) / 2, m--;
else
c += (m + 1) / 2;
} else {
if (query(r += (m + 1) / 2))
l += (m + 1) / 2, m--;
else
c += (m + 1) / 2;
}
printf("= %lld\n", c);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Colors.c: In function 'query':
Colors.c:7:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
7 | scanf("%d", &x);
| ^~~~~~~~~~~~~~~
Colors.c: In function 'main':
Colors.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lld", &n);
| ^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |