# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966643 | vjudge1 | Type Printer (IOI08_printer) | C++17 | 93 ms | 4692 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, pr1, pr2, pr, mx;
string arr[25010];
string l;
int pref(string s1, string s2) {
int i;
for(i=0; i<min(s1.size(), s2.size()); i++) if(s1[i] != s2[i]) return i;
return i;
}
bool cmp(string s1, string s2) {
pr1 = pref(s1, l);
pr2 = pref(s2, l);
if(pr1 == pr2) return s1 < s2;
return pr1 < pr2;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i=1; i<=n; i++) {
cin >> arr[i];
if(arr[i].size() > l.size()) l = arr[i];
}
sort(arr+1, arr+n+1, cmp);
for(int i=1; i<=n; i++) {
pr = pref(arr[i-1], arr[i]);
mx += arr[i-1].size() + arr[i].size() - 2*pr;
}
cout << mx + n << "\n";
for(int i=1; i<=n; i++) {
pr = pref(arr[i-1], arr[i]);
for(int j=arr[i-1].size(); j>pr; j--) cout << "-\n";
for(int j=pr; j<arr[i].size(); j++) cout << arr[i][j] << "\n";
cout << "P\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... |