# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503297 | rainboy | Hiperkocka (COCI21_hiperkocka) | C11 | 50 ms | 3808 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>
#include <stdlib.h>
#define N 16
int *ej[N + 1], eo[N + 1];
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;
}
int bb[N + 1], h;
void dfs(int p, int i, int b) {
int o;
bb[i] = b;
for (o = eo[i]; o--; ) {
int j = ej[i][o];
if (j != p)
dfs(i, j, b | 1 << h++);
}
}
int main() {
static int kk[1 << N];
int n, i, j, b;
scanf("%d", &n);
for (i = 0; i <= n; i++)
ej[i] = (int *) malloc(2 * sizeof *ej[i]);
for (h = 0; h < n; h++) {
scanf("%d%d", &i, &j);
append(i, j), append(j, i);
}
h = 0, dfs(-1, 0, 0);
for (b = 1; b < 1 << n; b++)
kk[b] = kk[b & b - 1] ^ 1;
printf("%d\n", 1 << n - 1);
for (b = 0; b < 1 << n; b++)
if (kk[b] == 0) {
for (i = 0; i <= n; i++)
printf("%d ", b ^ bb[i]);
printf("\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |