# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900654 | 2024-01-08T19:42:18 Z | vanea | Type Printer (IOI08_printer) | C++17 | 67 ms | 40960 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mxN = 5e5+10; int trie[mxN][26]; int cnt = 0; bool stop[mxN]; string alpha = "abcdefghijklmnopqrstuvwxyz"; void insert(string s) { int node = 0; for(auto c : s) { if(trie[node][c-'a'] == 0) trie[node][c-'a'] = ++cnt; node = trie[node][c-'a']; } stop[node] = true; } vector<char> ans; void dfs(int node) { if(stop[node]) ans.push_back('P'); for(auto c : alpha) { int k = trie[node][c-'a']; if(k) { ans.push_back(c); dfs(k); ans.push_back('-'); } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 0; i < n; i++) { string s; cin >> s; insert(s); } dfs(0); int curr = 0, mx = 0, idx; for(int i = 0; i < ans.size(); i++) { if(ans[i] == '-') curr++; else { if(curr > mx) { mx = curr; idx = i; } curr = 0; } } cout << ans.size() - mx << '\n'; for(int i = idx; i < ans.size(); i++) { cout << ans[i] << '\n'; } for(int i = 0; i < idx-mx; i++) { cout << ans[i] << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | printed invalid word |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1116 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3292 KB | Output is correct |
2 | Incorrect | 10 ms | 6492 KB | printed invalid word |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 7392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 18132 KB | Output is correct |
2 | Correct | 67 ms | 40960 KB | Output is correct |
3 | Incorrect | 38 ms | 21424 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 14300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |