# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060468 | 2024-08-15T15:43:52 Z | belgianbot | Type Printer (IOI08_printer) | C++17 | 30 ms | 17872 KB |
#include <bits/stdc++.h> using namespace std; vector<char> ans, letters; vector<vector<pair<int,int>>> adj; void dfs(int curr) { sort(adj[curr].begin(), adj[curr].end()); if (adj[curr].empty()) ans.push_back('P'); for (auto x : adj[curr]) { ans.push_back(letters[x.second]); dfs(x.second); ans.push_back('-'); } } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<string> words(N); for (int i = 0; i < N; i++) cin >> words[i]; sort(words.begin(), words.end()); int cnt = 1; letters.resize(N * 20 + 1); adj.resize(N * 20 + 1); for (int i = 0; i < N; i++) { int pos = 0; for (int j = 0; j < words[i].size(); j++) { bool exist = false; for (auto x : adj[pos]) { if (letters[x.second] == words[i][j]) { pos = x.second; exist = true; x.first = max(x.first, int(words[i].size()) - j - 1); break; } } if (!exist) { adj[pos].push_back({words[i].size() - j - 1, cnt}); letters[cnt] = words[i][j]; pos = cnt; cnt++; } } } dfs(0); int m = ans.size(); for (int i = m-1; ans[i] == '-'; i--) { ans.pop_back(); } m = ans.size(); cout << m << '\n'; for (int i = 0; i < m; i++) cout << ans[i] << '\n'; return 0; }
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 | Correct | 0 ms | 452 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 | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1128 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2908 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 7380 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 15828 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 17872 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |