# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997454 | 2024-06-12T10:50:36 Z | hasan2006 | Type Printer (IOI08_printer) | C++17 | 68 ms | 5584 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){ l = 0; for(i = 0; i < min(to.size(), d.size()); i++){ if(d[i] != to[i]) break; l++; } 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 | 344 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 | 0 ms | 344 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 | 348 KB | Output is correct |
2 | Correct | 2 ms | 344 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 | 14 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2524 KB | Output is correct |
2 | Correct | 54 ms | 4804 KB | Output is correct |
3 | Correct | 56 ms | 3696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2252 KB | Output is correct |
2 | Correct | 68 ms | 5584 KB | Output is correct |
3 | Correct | 50 ms | 4560 KB | Output is correct |
4 | Correct | 61 ms | 5328 KB | Output is correct |