# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997457 | 2024-06-12T10:54:16 Z | hasan2006 | Type Printer (IOI08_printer) | C++17 | 66 ms | 5068 KB |
#include <bits/stdc++.h> using namespace std; #define all(s) s.begin(),s.end() #define pb push_back #define ll long long vector<string>v; deque<char>d; vector<char>ans; string a; bool cmp(string b , string c){ int i = 0; for(i = 0; i < min(b.size() , c.size()); i++){ if(b[i] == c[i] && (b[i] == a[i])) continue; if(b[i] == a[i]) return 0; if(c[i] == a[i]) return 1; return b < c; } return (b.size() < c.size()); } void solve() { ll n , i , l , mx = 0; cin>>n; v.resize(n); for(i = 0; i < n; i++){ cin>>v[i]; if(v[i].size() > mx) mx = v[i].size() , a = v[i]; } sort(all(v) , cmp); for(auto to : v){ for(l = 0; l < min(to.size(), d.size()); l++) if(d[l] != to[l]) break; while(d.size() > l) ans.pb('-') , d.pop_back(); while(l < to.size()) ans.pb(to[l]) ,d.pb(to[l]) , l++; ans.pb('P'); } cout<<ans.size()<<"\n"; for(auto to : ans) cout<<char(to)<<"\n"; } int main(){ solve(); } // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 600 KB | Output is correct |
2 | Correct | 10 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1240 KB | Output is correct |
2 | Correct | 11 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 2264 KB | Output is correct |
2 | Correct | 54 ms | 4292 KB | Output is correct |
3 | Correct | 44 ms | 3280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2088 KB | Output is correct |
2 | Correct | 66 ms | 5068 KB | Output is correct |
3 | Correct | 48 ms | 3796 KB | Output is correct |
4 | Correct | 63 ms | 4812 KB | Output is correct |