| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 465375 | rainboy | Poklon (COCI17_poklon7) | C11 | 283 ms | 28600 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
