# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966655 | vjudge1 | Type Printer (IOI08_printer) | C++17 | 88 ms | 4688 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, dif, ans;
string s[25010];
string l;
int diff(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) {
int diff1 = diff(s1, l);
int diff2 = diff(s2, l);
if(diff1 == diff2) return s1 < s2;
return diff1 < diff2;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n; i++) {
cin >> s[i];
if(s[i].size() > l.size()) l = s[i];
}
sort(s+1, s+n+1, cmp);
for(int i=1; i<=n; i++) {
dif = diff(s[i-1], s[i]);
ans += s[i-1].size() + s[i].size() - 2*dif;
}
cout << ans + n << "\n";
for(int i=1; i<=n; i++) {
dif = diff(s[i-1], s[i]);
for(int j=s[i-1].size(); j>dif; j--) cout << "-\n";
for(int j=dif; j<s[i].size(); j++) cout << s[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... |