# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61882 | 2018-07-27T04:07:35 Z | 김세빈(#1797) | Zalmoxis (BOI18_zalmoxis) | C++11 | 367 ms | 53160 KB |
#include <bits/stdc++.h> using namespace std; struct zals{ int l, r, v; zals() {} zals(int v, int l, int r) : l(l), r(r), v(v) {} zals operator + (const zals& z) const { return zals(v + 1, l, z.r); } }; zals B[1010101], S[1010101]; int A[1010101]; vector <int> V[1010101]; int n, k, s, t; void print(int p) { if(k == 0 || p == 0) printf("%d ", p); else{ k --; print(p - 1); if(k == 0) printf("%d ", p - 1); else print(p - 1); } } int main() { int i, j; scanf("%d%d", &n, &k); for(i=1; i<=n; i++){ scanf("%d", A+i); B[i] = zals(A[i], i, i); } t = n; for(i=0; i<30; i++){ s = 0; for(j=1; j<=t; j++){ if(B[j].v == i){ if(s && S[s].v == i) S[s] = S[s] + B[j]; else S[++s] = B[j]; } else{ if(s && S[s].v == i){ V[S[s].r].push_back(i); k --; S[s].v = i + 1; } S[++s] = B[j]; } } if(s && S[s].v == i){ V[S[s].r].push_back(i); k --; S[s].v = i + 1; } t = s; for(j=1; j<=t; j++){ B[j] = S[j]; } } for(i=1; i<=n; i++){ printf("%d ", A[i]); for(int p: V[i]) print(p); } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 52472 KB | Output is correct |
2 | Correct | 271 ms | 52852 KB | Output is correct |
3 | Correct | 354 ms | 52852 KB | Output is correct |
4 | Correct | 295 ms | 52932 KB | Output is correct |
5 | Correct | 332 ms | 52932 KB | Output is correct |
6 | Correct | 313 ms | 52932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 367 ms | 52944 KB | Output is correct |
2 | Correct | 277 ms | 52944 KB | Output is correct |
3 | Correct | 313 ms | 53136 KB | Output is correct |
4 | Correct | 362 ms | 53136 KB | Output is correct |
5 | Correct | 321 ms | 53136 KB | Output is correct |
6 | Correct | 273 ms | 53136 KB | Output is correct |
7 | Correct | 285 ms | 53136 KB | Output is correct |
8 | Correct | 320 ms | 53160 KB | Output is correct |
9 | Correct | 337 ms | 53160 KB | Output is correct |
10 | Correct | 258 ms | 53160 KB | Output is correct |
11 | Correct | 310 ms | 53160 KB | Output is correct |
12 | Correct | 136 ms | 53160 KB | Output is correct |
13 | Correct | 165 ms | 53160 KB | Output is correct |
14 | Correct | 146 ms | 53160 KB | Output is correct |