# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484297 | rainboy | Magenta (COCI21_magenta) | C11 | 9 ms | 8908 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 100000
int ij[N], cc[N];
int *eh[N], eo[N];
void append(int i, int h) {
int o = eo[i]++;
if (o >= 2 && (o & o - 1) == 0)
eh[i] = (int *) realloc(eh[i], o * 2 * sizeof *eh[i]);
eh[i][o] = h;
}
int dd[N];
void dfs(int p, int i, int d) {
int o;
dd[i] = d;
for (o = eo[i]; o--; ) {
int h = eh[i][o], j = i ^ ij[h];
if (j != p)
dfs(i, j, d + 1);
}
}
int main() {
int n, u, v, h, i, j;
scanf("%d%d%d", &n, &u, &v), u--, v--;
for (i = 0; i < n; i++)
eh[i] = (int *) malloc(2 * sizeof *eh[i]);
for (h = 0; h < n - 1; h++) {
static char s[2];
int i, j;
scanf("%d%d%s", &i, &j, s), i--, j--;
ij[h] = i ^ j, cc[h] = s[h] == 'm' ? 0 : (s[h] == 'b' ? 1 : -1);
append(i, h), append(j, h);
}
dfs(-1, u, 0);
printf(dd[v] % 2 == 0 ? "Paula\n" : "Marin\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |