# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966651 | 2024-04-20T07:42:05 Z | njoop | Type Printer (IOI08_printer) | C++14 | 85 ms | 4652 KB |
#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
# | 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 | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1240 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 | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1112 KB | Output is correct |
2 | Correct | 3 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1372 KB | Output is correct |
2 | Correct | 16 ms | 1384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1372 KB | Output is correct |
2 | Correct | 24 ms | 1368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 2168 KB | Output is correct |
2 | Correct | 70 ms | 3920 KB | Output is correct |
3 | Correct | 68 ms | 3288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 1872 KB | Output is correct |
2 | Correct | 85 ms | 4652 KB | Output is correct |
3 | Correct | 72 ms | 3656 KB | Output is correct |
4 | Correct | 84 ms | 4432 KB | Output is correct |