# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377131 | 2021-03-13T03:33:06 Z | kevinxiehk | Type Printer (IOI08_printer) | C++17 | 120 ms | 5604 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define fi first #define se second #define ick cout<<"ickbmi32.9\n" using namespace std; string arr[25005]; int n; bool cmp(string a,string b){ for(int i=0;i<min(a.length(),b.length());i++){ if(a[i]==b[i])continue; if(a[i]==arr[n-1][i])return false; if(b[i]==arr[n-1][i])return true; return a[i]<b[i]; } return a.length()<b.length(); } bool cmp2(string a,string b){ return a.length()<b.length(); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>n; for(int i=0;i<n;i++)cin>>arr[i]; sort(arr,arr+n,cmp2); sort(arr,arr+n-1,cmp); vector<char>ans; for(int i=0;i<arr[0].length();i++)ans.pb(arr[0][i]); ans.pb('P'); for(int i=1;i<n;i++){ int p=0; while(p<min(arr[i].length(),arr[i-1].length())&&arr[i][p]==arr[i-1][p])p++; for(int j=0;j<arr[i-1].length()-p;j++)ans.pb('-'); for(;p<arr[i].length();p++)ans.pb(arr[i][p]); ans.pb('P'); } cout<<ans.size()<<'\n'; for(auto&x:ans)cout<<x<<'\n'; //for(int i=0;i<n;i++)cout<<arr[i]<<'\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 1 ms | 1260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 1 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 1 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 1 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1132 KB | Output is correct |
2 | Correct | 3 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1260 KB | Output is correct |
2 | Correct | 4 ms | 1260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1388 KB | Output is correct |
2 | Correct | 18 ms | 1772 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 1904 KB | Output is correct |
2 | Correct | 23 ms | 1644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 2660 KB | Output is correct |
2 | Correct | 100 ms | 4960 KB | Output is correct |
3 | Correct | 84 ms | 3940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 2284 KB | Output is correct |
2 | Correct | 120 ms | 5604 KB | Output is correct |
3 | Correct | 93 ms | 4240 KB | Output is correct |
4 | Correct | 115 ms | 5476 KB | Output is correct |