# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53703 | 2018-07-01T05:03:45 Z | 김세빈(#1437) | Type Printer (IOI08_printer) | C++11 | 30 ms | 2304 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, m; bool comp(int ca, int cb) { int i; for(i=0;i<m && str[ca][i] && str[cb][i];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]; } } if(!str[ca][i]) return 1; return 0; } int main() { int i, j, k; 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<m;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 | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 488 KB | Output is correct |
2 | Incorrect | 3 ms | 488 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 600 KB | Output is correct |
2 | Incorrect | 2 ms | 600 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 1248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 2288 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 2304 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |