# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742691 | peteza | Type Printer (IOI08_printer) | C++14 | 39 ms | 2392 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;
int n;
vector<pair<string, int>> inp;
string x, lng;
string cur;
queue<char> q;
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
for(int i=0;i<n;i++) {
cin >> x;
inp.emplace_back(x, -1);
if(x.size() > lng.size()) lng = x;
}
for(int i=0;i<n;i++) {
for(int j=0;j<inp[i].first.size();j++) {
if(inp[i].first[j] != lng[j]) {
inp[i].second = j;
break;
}
}
if(inp[i].second == -1) inp[i].second = x.size();
}
sort(inp.begin(), inp.end(), [](pair<string, int> a, pair<string, int> b){
if(a.second == b.second) return a.first < b.first;
else return a.second < b.second;
});
for(int i=0;i<n;i++) {
while(inp[i].first.substr(0, cur.size()) != cur) cur.pop_back(), q.push('-');
for(int j=cur.size();j<inp[i].first.size();j++) cur += inp[i].first[j], q.push(inp[i].first[j]);
q.push('P');
}
cout << q.size() << '\n';
while(!q.empty()) cout << q.front() << '\n', q.pop();
}
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... |