# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441579 | 2021-07-05T12:43:30 Z | rainboy | Type Printer (IOI08_printer) | C | 58 ms | 17860 KB |
#include <stdio.h> #include <string.h> #define N 25000 #define L 20 #define N_ (2 + N * L) #define A 26 int max(int a, int b) { return a > b ? a : b; } int tt[N_][A], dd[N_]; char word[N_]; void dfs1(int i) { int a; for (a = 0; a < A; a++) { int j = tt[i][a]; if (j) { dfs1(j); dd[i] = max(dd[i], dd[j] + 1); } } } void dfs2(int i) { int a, a_; if (word[i]) printf("P\n"); a_ = -1; for (a = 0; a < A; a++) { int j = tt[i][a]; if (j && dd[i] == dd[j] + 1) { a_ = a; break; } } for (a = 0; a < A; a++) { int j = tt[i][a]; if (j && a != a_) { printf("%c\n", a + 'a'); dfs2(j); printf("-\n"); } } if (a_ != -1) { printf("%c\n", a_ + 'a'); dfs2(tt[i][a_]); } } int main() { int n, n_, i; scanf("%d", &n); n_ = 2; for (i = 0; i < n; i++) { static char cc[L + 1]; int l, h, t; scanf("%s", cc), l = strlen(cc); for (h = 0, t = 1; h < l; h++) { int a = cc[h] - 'a'; if (!tt[t][a]) tt[t][a] = n_++; t = tt[t][a]; } word[t] = 1; } dfs1(1); printf("%d\n", n + (n_ - 2) * 2 - dd[1]); dfs2(1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 972 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 3020 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 7180 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 58 ms | 17860 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 14000 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |