# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063697 | 2024-08-17T23:39:06 Z | dyogorb | Type Printer (IOI08_printer) | C++14 | 54 ms | 6748 KB |
#include <bits/stdc++.h> using namespace std; const int WMAX = 3e4; int trie[WMAX][26]; int node_count; bool stop[WMAX]; string biggest; string ans; void insert(string word){ int node = 0; for (int i = 0; i < word.size(); i++) { char c = word[i]; if(trie[node][c - 'a'] == 0) trie[node][c - 'a'] = ++node_count; if(i == word.size() - 1)stop[node] = true; node = trie[node][c - 'a']; } } void dfs(int node, int depth, int flag){ for (int i = 0; i < 26; i++) { if((i != biggest[depth] - 'a' || !flag) && trie[node][i]){ char c = 'a' + i; ans += c; if(stop[node]) ans += 'P'; dfs(trie[node][i], depth + 1, 0); ans += '-'; } } if(depth < biggest.size() && trie[node][biggest[depth] - 'a'] && flag){ ans += biggest[depth]; if(depth == biggest.size() - 1) ans += 'P'; dfs(trie[node][biggest[depth] - 'a'], depth + 1, 1); } } int main(){ int n; cin >> n; string s; biggest = ""; for (int i = 0; i < n; i++) { cin >> s; insert(s); if(s.size() > biggest.size()) biggest = s; } dfs(0, 0, 1); cout << ans.size() << endl; for (auto c : ans) { cout << c << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 1116 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 54 ms | 3156 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 6748 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 6748 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 6748 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |