Submission #472981

# Submission time Handle Problem Language Result Execution time Memory
472981 2021-09-14T17:11:54 Z rainboy Birokracija (COCI18_birokracija) C
100 / 100
61 ms 6008 KB
#include <stdio.h>

#define N	200000

int main() {
	static int pp[N];
	static long long ans[N];
	int n, i;

	scanf("%d", &n);
	for (i = 1; i < n; i++)
		scanf("%d", &pp[i]), pp[i]--;
	for (i = 0; i < n; i++)
		ans[i] = 1;
	for (i = n - 1; i > 0; i--)
		ans[pp[i]] += ans[i];
	for (i = n - 1; i > 0; i--)
		ans[pp[i]] += ans[i];
	for (i = 0; i < n; i++)
		printf("%lld ", ans[i]);
	printf("\n");
	return 0;
}

Compilation message

birokracija.c: In function 'main':
birokracija.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
birokracija.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &pp[i]), pp[i]--;
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 552 KB Output is correct
2 Correct 7 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1572 KB Output is correct
2 Correct 21 ms 1632 KB Output is correct
3 Correct 18 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 4200 KB Output is correct
2 Correct 48 ms 4516 KB Output is correct
3 Correct 51 ms 6008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4164 KB Output is correct
2 Correct 61 ms 4488 KB Output is correct
3 Correct 49 ms 4616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 4076 KB Output is correct
2 Correct 49 ms 4420 KB Output is correct
3 Correct 50 ms 4832 KB Output is correct