# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249425 | 2020-07-15T01:34:24 Z | thebes | Zalmoxis (BOI18_zalmoxis) | C++14 | 288 ms | 47864 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 1e6+6, MM = 30; int N, K, i, j, cur, id, nxt, arr[MN], ds[MN], val[MN]; pair<int,int> b[MN]; vector<int> add[MN]; int fnd(int x){return ds[x]=x==ds[x]?x:fnd(ds[x]);} void expand(int x){ if(K>0&&x>0) K--, expand(x-1), expand(x-1); else printf("%d ",x); } int main(){ scanf("%d%d",&N,&K); for(i=1;i<=N;i++){ scanf("%d",&arr[i]); b[i] = {i, i}; ds[i] = i; val[i] = arr[i]; } for(j=0;j<MM;j++){ cur = 0; while(cur<N){ id = fnd(cur+1); if(val[id]==j){ nxt = fnd(b[id].second+1); if(b[id].second<N&&val[nxt]==j){ ds[nxt] = id; b[id].second = b[nxt].second; } else{ add[b[id].second].push_back(j); K--; } val[id]++; } cur = b[id].second; } } for(i=1;i<=N;i++){ printf("%d ",arr[i]); for(auto v : add[i]) expand(v); } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 288 ms | 47476 KB | Output is correct |
2 | Correct | 271 ms | 47480 KB | Output is correct |
3 | Correct | 264 ms | 47736 KB | Output is correct |
4 | Correct | 268 ms | 47480 KB | Output is correct |
5 | Correct | 268 ms | 47480 KB | Output is correct |
6 | Correct | 264 ms | 47736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 268 ms | 47480 KB | Output is correct |
2 | Correct | 263 ms | 47480 KB | Output is correct |
3 | Correct | 272 ms | 47864 KB | Output is correct |
4 | Correct | 269 ms | 47608 KB | Output is correct |
5 | Correct | 268 ms | 47608 KB | Output is correct |
6 | Correct | 268 ms | 47456 KB | Output is correct |
7 | Correct | 271 ms | 47612 KB | Output is correct |
8 | Correct | 271 ms | 47608 KB | Output is correct |
9 | Correct | 258 ms | 46584 KB | Output is correct |
10 | Correct | 177 ms | 34936 KB | Output is correct |
11 | Correct | 212 ms | 40184 KB | Output is correct |
12 | Correct | 116 ms | 25848 KB | Output is correct |
13 | Correct | 119 ms | 25852 KB | Output is correct |
14 | Correct | 115 ms | 25848 KB | Output is correct |