# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582408 | 2022-06-23T17:36:45 Z | mohammad_kilani | Type Printer (IOI08_printer) | C++17 | 39 ms | 5120 KB |
#include <bits/stdc++.h> using namespace std; #define oo 1000000010 #define mod 998244353 const int N = 25000; const int M = N * 20 + 1; string mx; bool compare(string &a,string &b){ for(int i = 0 ;i < (int)a.size() && i < (int)b.size();i++){ if(a[i] == b[i]) continue; if(a[i] == mx[i]) return false; if(b[i] == mx[i]) return true; return (a[i] < b[i]); } return (int)a.size() < (int)b.size(); } int main(){ int n; scanf("%d",&n); char tmpRead[21]; string s; vector< string > v; for(int i = 0 ;i < n;i++){ scanf("%s",tmpRead); s = (string)tmpRead; v.push_back(s); if((int)s.size() > (int)mx.size()) mx = s; } sort(v.begin(),v.end(), compare); string ans; for(int l, i = 0 ;i < (int)v.size();i++){ l = 0; if(i != 0){ while(l < (int)v[i].size() && l < (int)v[i - 1].size() && v[i][l] == v[i - 1][l]) l++; for(int j = (int)v[i - 1].size();j > l;j--){ ans += '-'; } } for(int j = l;j < (int)v[i].size();j++){ ans += v[i][j]; } ans += 'P'; } printf("%d\n",(int)ans.size()); for(int i = 0 ;i < (int)ans.size();i++){ putchar(ans[i]); puts(""); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 596 KB | Output is correct |
2 | Correct | 7 ms | 976 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 1228 KB | Output is correct |
2 | Correct | 7 ms | 1104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 2432 KB | Output is correct |
2 | Correct | 31 ms | 4348 KB | Output is correct |
3 | Correct | 24 ms | 3696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 2340 KB | Output is correct |
2 | Correct | 39 ms | 5120 KB | Output is correct |
3 | Correct | 29 ms | 4084 KB | Output is correct |
4 | Correct | 34 ms | 4988 KB | Output is correct |