# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
349253 | 2021-01-17T09:13:35 Z | jenny00513 | Type Printer (IOI08_printer) | C++14 | 44 ms | 3432 KB |
#include <bits/stdc++.h> using namespace std; int n; string st; string s[25005]; vector<char> print; vector<string> last; string nvr = "This should not be printed!"; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> s[i]; sort(s + 1, s + n + 1); char start = NULL; int mx = 0; int pos; for (int i = 1; i <= n; i++) { if (s[i].size() > mx) { start = (char)s[i][0], mx = s[i].size(); pos = i; } } int ss = -1, ee = -1; for (int i = 1; i <= n; i++) { if (ss == -1 && (char)s[i][0] == start) ss = i; if (ee == -1 && ((char)s[i + 1][0] != start || i == n)) { ee = i; break; } } for (int i = ss; i <= pos; i++) { last.push_back(s[i]); s[i] = nvr; } for (int i = 1; i <= n; i++) { if ((char)s[i][0] == start) continue; if (s[i] == nvr) continue; while (true) { if (st == s[i].substr(0, st.size())) break; st = st.substr(0, (int)st.size() - 1); print.push_back('-'); } for (int k = st.size(); k < s[i].size(); k++) print.push_back((char)s[i][k]); print.push_back('P'); st = s[i]; } for (int i = 1; i <= n; i++) { if ((char)s[i][0] != start) continue; if (s[i] == nvr) continue; while (true) { if (st == s[i].substr(0, st.size())) break; st = st.substr(0, (int)st.size() - 1); print.push_back('-'); } for (int k = st.size(); k < s[i].size(); k++) print.push_back((char)s[i][k]); print.push_back('P'); st = s[i]; } for (int i = 0; i < last.size(); i++) { while (true) { if (st == last[i].substr(0, st.size())) break; st = st.substr(0, (int)st.size() - 1); print.push_back('-'); } for (int k = st.size(); k < last[i].size(); k++) print.push_back((char)last[i][k]); print.push_back('P'); st = last[i]; } printf("%d\n", print.size()); for (char each : print) printf("%c\n", each); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 1 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 2156 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 2156 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 2156 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 2156 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 2284 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 2540 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 3432 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 2660 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 18 ms | 3176 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |