# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970452 | 2024-04-26T14:37:41 Z | jadai007 | Type Printer (IOI08_printer) | C++14 | 86 ms | 4708 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 2 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1116 KB | Output is correct |
2 | Correct | 3 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1368 KB | Output is correct |
2 | Correct | 15 ms | 1372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 1612 KB | Output is correct |
2 | Correct | 28 ms | 1372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 2132 KB | Output is correct |
2 | Correct | 81 ms | 3916 KB | Output is correct |
3 | Correct | 70 ms | 3460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 1872 KB | Output is correct |
2 | Correct | 86 ms | 4708 KB | Output is correct |
3 | Correct | 73 ms | 3668 KB | Output is correct |
4 | Correct | 85 ms | 4424 KB | Output is correct |