# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
721322 | 2023-04-10T16:46:41 Z | thimote75 | Type Printer (IOI08_printer) | C++14 | 120 ms | 57936 KB |
#include <bits/stdc++.h> using namespace std; vector<char> chr_buffer; struct Trie { map<char, Trie*> m; int count = 0; int mxSize = 0; void append (string &buffer, int offset) { if (offset == buffer.size()) { count ++; return ; } mxSize = max(mxSize, (int) buffer.size()); if (m.find(buffer[offset]) == m.end()) m.insert({ buffer[offset], new Trie() }); Trie* tr = (*m.find(buffer[offset])).second; tr->append(buffer, offset + 1); } void show () { for (int i = 0; i < count; i ++) chr_buffer.push_back('P'); bool found = false; for (auto u : m) { if (u.second->mxSize == mxSize && !found) { found = true; continue ; } chr_buffer.push_back(u.first); u.second->show(); chr_buffer.push_back('-'); } for (auto u : m) { if (u.second->mxSize != mxSize) continue ; chr_buffer.push_back(u.first); u.second->show(); chr_buffer.push_back('-'); break; } } }; Trie res; int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; string b; for (int i = 0; i < N; i ++) { cin >> b; res.append(b, 0); } res.show(); while (chr_buffer[chr_buffer.size() - 1] == '-') chr_buffer.pop_back(); cout << chr_buffer.size() << '\n'; for (char c : chr_buffer) cout << c << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1108 KB | Output is correct |
2 | Correct | 3 ms | 1364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3564 KB | Output is correct |
2 | Correct | 13 ms | 7408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 8700 KB | Output is correct |
2 | Correct | 7 ms | 2004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 21456 KB | Output is correct |
2 | Correct | 111 ms | 48708 KB | Output is correct |
3 | Correct | 59 ms | 25152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 16716 KB | Output is correct |
2 | Correct | 120 ms | 57936 KB | Output is correct |
3 | Correct | 74 ms | 29032 KB | Output is correct |
4 | Correct | 94 ms | 55224 KB | Output is correct |