# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245830 | 2020-07-07T14:35:12 Z | kevlee | Type Printer (IOI08_printer) | C++17 | 89 ms | 6256 KB |
#include <bits/stdc++.h> using namespace std; char s[25005][27]; int n, maxi, maxx; pair<pair<int, string>, int>p[25005]; int main () { scanf("%d", &n); for (int i=0; i<n; i++) { scanf("%s", s[i]); int len=strlen(s[i]); if (len>maxx) { maxx=len; maxi=i; } } for (int i=0; i<n; i++) { int cnt=0; for (int j=0; j<maxx; j++) { if (s[i][j]!=s[maxi][j]) break; cnt++; } string tmp=s[i]; p[i]={{cnt, tmp}, i}; } sort(p, p+n); string prev=""; vector<char>v; for (int i=0; i<n; i++) { int cnt=0; string cur=p[i].first.second; for (int j=0; j<prev.size(); j++) { if (prev[j]!=cur[j]) break; cnt++; } for (int j=0; j<prev.size()-cnt; j++) v.push_back('-'); for (int j=cnt; j<cur.size(); j++) v.push_back(cur[j]); v.push_back('P'); prev=cur; } printf("%d\n", v.size()); for (int i=0; i<v.size(); i++) printf("%c\n", v[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1536 KB | Output is correct |
2 | Correct | 5 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1536 KB | Output is correct |
2 | Correct | 5 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1536 KB | Output is correct |
2 | Correct | 5 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1536 KB | Output is correct |
2 | Correct | 5 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1536 KB | Output is correct |
2 | Correct | 6 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1664 KB | Output is correct |
2 | Correct | 7 ms | 1664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1920 KB | Output is correct |
2 | Correct | 19 ms | 2304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 2428 KB | Output is correct |
2 | Correct | 17 ms | 2304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 3440 KB | Output is correct |
2 | Correct | 82 ms | 5608 KB | Output is correct |
3 | Correct | 48 ms | 4464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 3312 KB | Output is correct |
2 | Correct | 89 ms | 6256 KB | Output is correct |
3 | Correct | 54 ms | 4728 KB | Output is correct |
4 | Correct | 78 ms | 6128 KB | Output is correct |