# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
396166 | 2021-04-29T14:03:38 Z | Berted | Type Printer (IOI08_printer) | C++14 | 1000 ms | 19108 KB |
#include <iostream> using namespace std; const int INF = 1e8; int N; string ans; int adj[500001][26], cnt[500001], DP[500001], sz = 0; inline int newNode() { for (int i = 0; i < 26; i++) adj[sz][i] = -1; return sz++; } inline void insert(int u, int i, const string& s) { if (i < s.size()) { int &v = adj[u][s[i] - 'a']; if (v == -1) {v = newNode();} insert(v, i + 1, s); DP[u] = max(DP[u], DP[v]) + 1; } else {cnt[u]++; DP[u] = 1;} } inline void solve(int u, bool m) { int hvy = -1; for (int i = 0; i < cnt[u]; i++) ans.push_back('P'); for (int i = 0; i < 26; i++) { if (adj[u][i] != -1 && m && (hvy == -1 || DP[adj[u][i]] > DP[adj[u][hvy]])) hvy = i; } for (int i = 0; i < 26; i++) { if (adj[u][i] != -1 && hvy != i) { ans.push_back(i + 'a'); solve(adj[u][i], 0); ans.push_back('-'); } } if (hvy != -1) {ans.push_back(hvy + 'a'); solve(adj[u][hvy], 1);} } int main() { cin >> N; newNode(); for (int i = 0; i < N; i++) {string S; cin >> S; insert(0, 0, S);} solve(0, 1); cerr << ans.size() << "\n"; for (const char &c : ans) cerr << c << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 332 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 47 ms | 1096 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 172 ms | 3296 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 427 ms | 7748 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1058 ms | 19108 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 858 ms | 14992 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |