# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083546 | 2024-09-03T13:09:22 Z | SulA | Type Printer (IOI08_printer) | C++17 | 40 ms | 36128 KB |
#include <bits/stdc++.h> using namespace std; struct trie { trie* child[26] = {}; bool end = false; void insert(const string& s, int ind = 0) { if (ind == s.size()) { end = true; } else { if (child[ s[ind] - 'a' ] == nullptr) child[ s[ind] - 'a' ] = new trie(); child[ s[ind] - 'a' ]->insert(s, ind + 1); } } void dfs(const string& longest, int ind = 0, bool branch = true) { if (end) { cout << "P\n"; } if (branch) { for (int i = 0; i < 26; i++) if (i + 'a' != longest[ind] && child[i] != nullptr) { cout << char(i + 'a') << "\n"; child[i]->dfs(longest, ind + 1, false); cout << "-\n"; } if (ind < longest.size()) { cout << longest[ind] << '\n'; child[ longest[ind] - 'a' ]->dfs(longest, ind + 1, true); } } else { for (int i = 0; i < 26; i++) if (child[i] != nullptr) { cout << char(i + 'a') << "\n"; child[i]->dfs(longest, ind + 1, false); cout << "-\n"; } } } }; trie* root = new trie(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; string longest; while (n--) { string s; cin >> s; root->insert(s); if (s.size() > longest.size()) { swap(s, longest); } } root->dfs(longest); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Expected integer, but "t" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Expected integer, but "e" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Expected integer, but "h" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Expected integer, but "b" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1880 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5980 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 14684 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 40 ms | 36128 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 28244 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |