# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503304 | 2022-01-07T15:59:23 Z | rainboy | Cijanobakterije (COCI21_cijanobakterije) | C | 28 ms | 12260 KB |
#include <stdio.h> #include <stdlib.h> #define N 100000 int max(int a, int b) { return a > b ? a : b; } 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; } int d1; int dfs(int p, int i) { int o, d_; d_ = 0; for (o = eo[i]; o--; ) { int j = ej[i][o]; if (j != p) { int d = dfs(i, j); d1 = max(d1, d_ + 1 + d), d_ = max(d_, d); } } return d_ + 1; } int main() { int n, m, i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) ej[i] = (int *) malloc(2 * sizeof *ej[i]); while (m--) { scanf("%d%d", &i, &j), i--, j--; append(i, j); } d1 = 1, dfs(-1, 0); printf("%d\n", d1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 972 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 12260 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 972 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |