# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
739859 | Desh03 | Type Printer (IOI08_printer) | C++17 | 27 ms | 2320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, t = 0, p = 0;
cin >> n;
vector<string> s(n);
vector<char> ans;
for (string &x : s) cin >> x;
sort(s.begin(), s.end(), [&] (const string &s1, const string &s2) {
return s1.size() == s2.size() ? s1 < s2 : s1.size() < s2.size();
});
string cur;
while (1) {
while (cur != s[t]) {
cur.push_back(s[t][p]);
ans.push_back(s[t][p++]);
}
ans.push_back('P');
if (t == n - 1) break;
t++;
while (cur.substr(0, p) != s[t].substr(0, p)) {
ans.push_back('-');
cur.pop_back(), --p;
}
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |