# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440491 | 2021-07-02T10:22:14 Z | dxz05 | Type Printer (IOI08_printer) | C++14 | 1000 ms | 7056 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define SZ(x) (int)(x).size() const int MAXN = 1e5 + 3e2; string str[MAXN]; int main(){ ios_base::sync_with_stdio(false); int n; cin >> n; int ind = 0; for (int i = 1; i <= n; i++){ cin >> str[i]; if (str[i].size() > str[ind].size()) ind = i; } string longest = str[ind]; for (int i = 1; i <= n; i++){ int j = 0; while (j < str[i].size() && j < longest.size() && str[i][j] == longest[j]) j++; str[i] = string(j, '{') + str[i]; } sort(str + 1, str + n + 1); vector<char> ans; for (int it = 1; it <= n; it++){ int j = 0; while (j < str[it].size() && str[it][j] == '{') j++; str[it].erase(0, j); string s = str[it], t = str[it - 1]; if (SZ(t) > SZ(s)){ int need = SZ(t) - SZ(s); while (need--) ans.push_back('-'); t.resize(s.size()); } int cnt = 0; for (int i = 0; i < min(SZ(t), SZ(s)); i++){ if (t[i] == s[i]) cnt++; else break; } int need = max(0, SZ(t) - cnt); while (need--){ ans.push_back('-'); } for (int i = cnt; i < s.size(); i++){ ans.push_back(s[i]); } ans.push_back('P'); } cout << ans.size() << endl; for (char c : ans) cout << c << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 3 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3404 KB | Output is correct |
2 | Correct | 14 ms | 3484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 3512 KB | Output is correct |
2 | Correct | 29 ms | 3560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 3608 KB | Output is correct |
2 | Correct | 177 ms | 3980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 208 ms | 3964 KB | Output is correct |
2 | Correct | 63 ms | 3780 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 526 ms | 4780 KB | Output is correct |
2 | Execution timed out | 1089 ms | 6904 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 425 ms | 4288 KB | Output is correct |
2 | Execution timed out | 1088 ms | 7056 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |