# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53687 | 2018-07-01T04:44:30 Z | 강한남자킹현수(#2036) | Type Printer (IOI08_printer) | C++11 | 70 ms | 18600 KB |
#include <bits/stdc++.h> using namespace std; const int N = 50001; struct Nod{ int c[26], d; } a[20 * N]; int n, c, v; int g(int x){ for(int i = 0; i < 26; i++){ if(!a[x].c[i]) continue; a[x].d = max(a[x].d, g(a[x].c[i]) + 1); } return a[x].d; } void f(int x){ if(!a[x].d){ puts("P"); v--; return; } int p, m = -1; for(int i = 0; i < 26; i++){ if(!a[x].c[i]) continue; if(a[a[x].c[i]].d > m){ m = a[a[x].c[i]].d; p = i; } } for(int i = 0; i < 26; i++){ if(i == p || !a[x].c[i]) continue; printf("%c\n", i + 'a'); v--; f(a[x].c[i]); puts("-"); v--; } printf("%c\n", p + 'a'); v--; f(a[x].c[p]); if(v){ puts("-"); v--; } } int main(){ scanf("%d", &n); for(int i = 0; i < n; i++){ char b[21]; scanf("%s", b); for(int j = 0, t = 0; b[j]; j++){ b[j] -= 'a'; if(!a[t].c[b[j]]) a[t].c[b[j]] = ++c; t = a[t].c[b[j]]; } } g(0); v = n + 2 * c - a[0].d; printf("%d\n", v); f(0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 420 KB | Output is correct |
2 | Correct | 2 ms | 532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 624 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 628 KB | Output is correct |
2 | Incorrect | 2 ms | 632 KB | didn't print every word |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 764 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1392 KB | Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 3464 KB | Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 7872 KB | Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 70 ms | 18600 KB | Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 67 ms | 18600 KB | Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |