제출 #465375

#제출 시각아이디문제언어결과실행 시간메모리
465375rainboyPoklon (COCI17_poklon7)C11
120 / 120
283 ms28600 KiB
#include <stdio.h>

#define N	1000000

int max(int a, int b) { return a > b ? a : b; }

int ll[N + 1], rr[N + 1], cc[N + 1], mx[N + 1];

void dfs(int i, int d) {
	if (i <= 0)
		mx[d] = max(mx[d], -i);
	else
		dfs(ll[i], d + 1), dfs(rr[i], d + 1);
}

void print(int a) {
	if (a == 0)
		return;
	print(a / 2);
	printf("%d", a % 2);
}

int main() {
	int n, i, d, d_;

	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		scanf("%d%d", &ll[i], &rr[i]);
	dfs(1, 0);
	d_ = 0;
	for (d = 1; d <= n; d++)
		if ((d - d_ > 30 ? 0 : (mx[d_] >> d - d_)) < mx[d])
			d_ = d;
	if (mx[d_] == 0)
		printf("0\n");
	else {
		print(mx[d_]);
		while (d_--)
			printf("0");
		printf("\n");
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

poklon.c: In function 'main':
poklon.c:32:39: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   32 |   if ((d - d_ > 30 ? 0 : (mx[d_] >> d - d_)) < mx[d])
      |                                     ~~^~~~
poklon.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
poklon.c:28:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d%d", &ll[i], &rr[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...