# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115665 | 2024-11-20T18:28:18 Z | Nahuepera | Type Printer (IOI08_printer) | C++17 | 46 ms | 37488 KB |
#include <bits/stdc++.h> #define tip tuple<int, string> using namespace std; struct TrieNodeStruct { TrieNodeStruct* children[26]; bool isEndOfWord; TrieNodeStruct() { isEndOfWord = false; for(int i = 0; i < 26; i++) { children[i] = nullptr; } } }; struct TrieStruct { TrieNodeStruct* root; TrieStruct() { root = new TrieNodeStruct(); } string insert(string word) { TrieNodeStruct* current = root; string res = ""; for(char c : word) { int index = c - 'a'; if(current->children[index] == nullptr) { current->children[index] = new TrieNodeStruct(); } else{ res += c; } current = current->children[index]; } current->isEndOfWord = true; return res; } }; int main(){ int n; cin >> n; vector<tip> lst(n); for(int i = 0; i < n; i++){ string s; cin >> s; lst[i] = make_tuple(s.length(), s); } sort(lst.begin(), lst.end()); TrieStruct t; string res = ""; int size = 0; auto [nl, sl] = lst[0]; t.insert(sl); int last = nl; for(int j = 0; j < nl; j++){ res += sl[j]; res += '\n'; size++; } res += 'P'; res += '\n'; size++; for(int i = 1; i < n; i++){ auto [n, s] = lst[i]; string r = t.insert(s); // cout << s << ": " << r << '\n'; for(int j = 0; j < last - r.length(); j++){ res += '-'; res += '\n'; size++; } for(int j = 0 + r.length(); j < n; j++){ res += s[j]; res += '\n'; size++; } res += 'P'; res += '\n'; size++; last = n; } cout << size << '\n'; cout << res; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Incorrect | 1 ms | 336 KB | printed invalid word |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1872 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 5968 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 15196 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 37488 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 29552 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |