# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121448 | 2019-06-26T14:16:56 Z | TadijaSebez | Type Printer (IOI08_printer) | C++11 | 64 ms | 4332 KB |
#include <stdio.h> #include <vector> #include <cstring> #include <algorithm> using namespace std; #define pb push_back const int N=25050; char s[N][21]; int len[N],heavy; bool comp(int a, int b) { int i; for(i=0;i<20;i++) if(s[a][i]!=s[b][i]) break; if(s[a][i]==s[heavy][i]) return 0; if(s[b][i]==s[heavy][i]) return 1; return s[a][i]<s[b][i]; } int id[N]; vector<char> sol; int main() { int n,i; scanf("%i",&n); for(i=1;i<=n;i++) { id[i]=i; scanf("%s",s[i]); len[i]=strlen(s[i]); if(len[heavy]<len[i]) heavy=i; } sort(id+1,id+1+n,comp); int j,k=-1; for(i=1;i<=n;i++) { if(i>1) { k=len[id[i-1]]; for(j=0;j<len[id[i-1]];j++){ if(s[id[i]][j]!=s[id[i-1]][j]) break;k--;} for(j=0;j<k;j++) sol.pb('-'); k=len[id[i-1]]-k-1; } for(j=k+1;j<len[id[i]];j++) sol.pb(s[id[i]][j]); sol.pb('P'); } printf("%i\n",sol.size()); for(i=0;i<sol.size();i++) printf("%c\n",sol[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 640 KB | Output is correct |
2 | Correct | 9 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1148 KB | Output is correct |
2 | Correct | 9 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 2128 KB | Output is correct |
2 | Correct | 47 ms | 3816 KB | Output is correct |
3 | Correct | 33 ms | 2676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 2160 KB | Output is correct |
2 | Correct | 64 ms | 4332 KB | Output is correct |
3 | Correct | 36 ms | 3056 KB | Output is correct |
4 | Correct | 51 ms | 4176 KB | Output is correct |