# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122183 | 2019-06-27T19:30:35 Z | thebes | Type Printer (IOI08_printer) | C++14 | 49 ms | 2676 KB |
#include <bits/stdc++.h> using namespace std; string s, arr[25005], lol; int n, i, j, x, ord[26], nxt=25; vector<char> mv; bool cmp(string i,string j){ for(int ii=0;ii<min(i.size(),j.size());ii++){ if(i[ii]!=j[ii]) return ord[i[ii]-'a']<ord[j[ii]-'a']; } return i.size()<j.size(); } int main(){ for(scanf("%d",&n),i=1;i<=n;i++){ cin >> arr[i]; if(arr[i].size()>lol.size()) lol = arr[i]; } for(auto v : lol){ if(ord[v-'a']) continue; ord[v-'a']=nxt--; } for(i=25;i>=0;i--){ if(ord[i]) continue; ord[i]=nxt--; } sort(arr+1,arr+n+1,cmp); for(i=1;i<=n;i++){ for(j=0;j<min(s.size(),arr[i].size());j++){ if(s[j]!=arr[i][j]) break; } while(s.size()>j){ mv.push_back('-'); s.pop_back(); } while(s.size()<arr[i].size()){ s.push_back(arr[i][s.size()]); mv.push_back(arr[i][s.size()-1]); } mv.push_back('P'); } printf("%d\n",mv.size()); for(auto v : mv) printf("%c\n",v); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Incorrect | 3 ms | 1024 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1024 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1280 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 1652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 49 ms | 2676 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 2160 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |