# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
369411 | 2021-02-21T15:21:22 Z | NachoLibre | Type Printer (IOI08_printer) | C++17 | 177 ms | 98704 KB |
#include <bits/stdc++.h> #define sz(a) ((int)a.size()) using namespace std; struct cac { cac *a[26]; int l; bool p; cac() : p(0), l(26) { for(int i = 0; i < 26; ++i) a[i] = NULL; } } *rt = new cac(); int n, w; string s, l; void G(cac *x) { for(int i = 0; i < 26; ++i) { if(i != x->l && x->a[i] != NULL) { cout << (char)('a' + i) << "\n"; if(x->a[i]->p) cout << "P\n"; G(x->a[i]); cout << "-\n"; } } if(x->l != 26) { cout << (char)('a' + x->l) << "\n"; if(x->a[x->l]->p) cout << "P\n"; G(x->a[x->l]); } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n; ++i) { cin >> s; if(sz(s) > sz(l)) l = s; cac *dg = rt; for(int j = 0; j < sz(s); ++j) { if(dg->a[s[j] - 'a'] == NULL) { w += 2; dg->a[s[j] - 'a'] = new cac(); } dg = dg->a[s[j] - 'a']; } dg->p = 1; } { cac *dg = rt; for(int i = 0; i < sz(l); ++i) { dg->l = l[i] - 'a'; dg = dg->a[dg->l]; } } cout << w - sz(l) + n << "\n"; G(rt); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 520 KB | Output is correct |
2 | Correct | 2 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1900 KB | Output is correct |
2 | Correct | 4 ms | 2432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 5868 KB | Output is correct |
2 | Correct | 20 ms | 12396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 14572 KB | Output is correct |
2 | Correct | 8 ms | 3308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 36204 KB | Output is correct |
2 | Correct | 131 ms | 82924 KB | Output is correct |
3 | Correct | 70 ms | 42732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 28396 KB | Output is correct |
2 | Correct | 177 ms | 98704 KB | Output is correct |
3 | Correct | 78 ms | 48492 KB | Output is correct |
4 | Correct | 133 ms | 93164 KB | Output is correct |