# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53699 | 2018-07-01T04:56:52 Z | 김세빈(#1437) | Type Printer (IOI08_printer) | C++11 | 40 ms | 2312 KB |
#include <bits/stdc++.h> using namespace std; char V[1010101], s[22], str[30303][22]; int K[30303]; int n, p, ans, x, t; bool comp(int ca, int cb) { int i; for(i=0;i<20;i++){ if(str[ca][i] != str[cb][i]){ if(i == x){ if(str[ca][i] == str[t][i]) return 0; if(str[cb][i] == str[t][i]) return 1; } return str[ca][i] < str[ca][i]; } } return 0; } int main() { int i, j, k, m=-1; int l, r; scanf("%d", &n); for(i=0;i<n;i++){ scanf("%s",str[i]); k = strlen(str[i]); if(k > m) m = k, t = i; K[i] = i; } l = 0, r = n; for(x=0;x<20;x++){ sort(K+l, K+r, comp); for(j=l; j<r; j++) if(K[j] == t) break; for(l=j; l >= 0 && str[K[l]][x] == str[t][x]; l--); l++; for(r=j; r < n && str[K[r]][x] == str[t][x]; r++); } for(i=0;i<n;i++){ for(j=0;j<p && str[K[i]][j];j++) if(s[j] != str[K[i]][j]) break; for(;j<p;p--) V[ans++] = '-'; for(;str[K[i]][j];j++) s[p++] = V[ans++] = str[K[i]][j]; V[ans++] = 'P'; } printf("%d\n", ans); for(i=0;i<ans;i++) printf("%c\n", V[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 452 KB | Output is correct |
2 | Correct | 3 ms | 452 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 452 KB | Output is correct |
2 | Incorrect | 2 ms | 452 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 488 KB | Output is correct |
2 | Incorrect | 2 ms | 536 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 536 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 868 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 1268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 29 ms | 2292 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 40 ms | 2312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |