제출 #544751

#제출 시각아이디문제언어결과실행 시간메모리
544751rainboyColors (BOI20_colors)C11
100 / 100
4 ms300 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...