Submission #412386

# Submission time Handle Problem Language Result Execution time Memory
412386 2021-05-26T19:11:08 Z rainboy Saveit (IOI10_saveit) C
50 / 100
391 ms 12684 KB
#include "grader.h"
#include "encoder.h"
#include <stdlib.h>

#define N	1000

int *ej[N], eo[N];

void append(int i, int j) {
	int o = eo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
	ej[i][o] = j;
}

void bfs(int n, int s) {
	static int dd[N], qu[N];
	int i, g, head, cnt;

	for (i = 0; i < n; i++)
		dd[i] = n;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = eo[i]; o--; ) {
			int j = ej[i][o];

			if (dd[j] > d)
				dd[j] = d, qu[head + cnt++] = j;
		}
	}
	for (i = 0; i < n; i++)
		for (g = 0; g < 10; g++)
			encode_bit(dd[i] >> g & 1);
}

void encode(int n, int k, int m, int *ii, int *jj) {
	int h, i;

	for (i = 0; i < n; i++)
		ej[i] = (int *) malloc(2 * sizeof *ej[i]);
	for (h = 0; h < m; h++)
		append(ii[h], jj[h]), append(jj[h], ii[h]);
	for (i = 0; i < k; i++)
		bfs(n, i);
}
#include "grader.h"
#include "decoder.h"

void decode(int n, int k) {
	int g, i, j;

	for (i = 0; i < k; i++)
		for (j = 0; j < n; j++) {
			int d = 0;

			for (g = 0; g < 10; g++)
				if (decode_bit())
					d |= 1 << g;
			hops(i, j, d);
		}
}

Compilation message

encoder.c: In function 'append':
encoder.c:12:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   12 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 391 ms 12684 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4452 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 79 ms 7212 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4580 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 87 ms 7392 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7680 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 110 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 81 ms 7416 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 99 ms 7464 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 81 ms 7556 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 81 ms 7684 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 81 ms 7460 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 111 ms 8196 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 82 ms 7512 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 83 ms 7580 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 122 ms 7924 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 113 ms 7896 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 109 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 92 ms 7916 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 138 ms 8572 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 144 ms 8564 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 126 ms 8220 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 170 ms 8944 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 391 ms 12684 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4452 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 79 ms 7212 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4580 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 87 ms 7392 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7680 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 110 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 81 ms 7416 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 99 ms 7464 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 81 ms 7556 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 81 ms 7684 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 81 ms 7460 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 111 ms 8196 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 82 ms 7512 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 83 ms 7580 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 122 ms 7924 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 113 ms 7896 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 109 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 92 ms 7916 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 138 ms 8572 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 144 ms 8564 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 126 ms 8220 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 170 ms 8944 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 391 ms 12684 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4452 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 79 ms 7212 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4580 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 87 ms 7392 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7680 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 110 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 81 ms 7416 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 99 ms 7464 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 81 ms 7556 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 81 ms 7684 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 81 ms 7460 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 111 ms 8196 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 82 ms 7512 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 83 ms 7580 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 122 ms 7924 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 113 ms 7896 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 109 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 92 ms 7916 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 138 ms 8572 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 144 ms 8564 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 126 ms 8220 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 170 ms 8944 KB Output is partially correct - 360000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 391 ms 12684 KB Output is partially correct - 360000 call(s) of encode_bit()
2 Correct 3 ms 4452 KB Output is correct - 150 call(s) of encode_bit()
3 Correct 79 ms 7212 KB Output is partially correct - 324000 call(s) of encode_bit()
4 Correct 3 ms 4580 KB Output is correct - 250 call(s) of encode_bit()
5 Correct 87 ms 7392 KB Output is partially correct - 324000 call(s) of encode_bit()
6 Correct 83 ms 7680 KB Output is partially correct - 360000 call(s) of encode_bit()
7 Correct 110 ms 8060 KB Output is partially correct - 360000 call(s) of encode_bit()
8 Correct 81 ms 7416 KB Output is partially correct - 345960 call(s) of encode_bit()
9 Correct 99 ms 7464 KB Output is partially correct - 360000 call(s) of encode_bit()
10 Correct 81 ms 7556 KB Output is partially correct - 360000 call(s) of encode_bit()
11 Correct 81 ms 7684 KB Output is partially correct - 360000 call(s) of encode_bit()
12 Correct 81 ms 7460 KB Output is partially correct - 360000 call(s) of encode_bit()
13 Correct 111 ms 8196 KB Output is partially correct - 360000 call(s) of encode_bit()
14 Correct 82 ms 7512 KB Output is partially correct - 360000 call(s) of encode_bit()
15 Correct 83 ms 7580 KB Output is partially correct - 360000 call(s) of encode_bit()
16 Correct 122 ms 7924 KB Output is partially correct - 360000 call(s) of encode_bit()
17 Correct 113 ms 7896 KB Output is partially correct - 360000 call(s) of encode_bit()
18 Correct 109 ms 8328 KB Output is partially correct - 360000 call(s) of encode_bit()
19 Correct 92 ms 7916 KB Output is partially correct - 360000 call(s) of encode_bit()
20 Correct 138 ms 8572 KB Output is partially correct - 360000 call(s) of encode_bit()
21 Correct 144 ms 8564 KB Output is partially correct - 360000 call(s) of encode_bit()
22 Correct 126 ms 8220 KB Output is partially correct - 360000 call(s) of encode_bit()
23 Correct 170 ms 8944 KB Output is partially correct - 360000 call(s) of encode_bit()