# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65186 | spencercompton | Zalmoxis (BOI18_zalmoxis) | C++14 | 544 ms | 83568 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, k;
void f(int now){
if(now==0 || k==0){
cout << " " << now;
return;
}
k--;
f(now-1);
f(now-1);
}
int main(){
cin >> n >> k;
vector<pair<int, int> > li;
for(int i = 0; i<n; i++){
int x;
cin >> x;
li.push_back(make_pair(i,x));
}
vector<pair<int, int> > cur;
cur = li;
vector<int> add[n];
int use = 0;
for(int i = 0; i<30; i++){
vector<pair<int, int> > nxt;
nxt.push_back(cur[0]);
for(int j = 1; j<cur.size(); j++){
int bef = nxt.back().second;
int now = cur[j].second;
if(bef==i){
if(now==i){
nxt.back().second++;
nxt.back().first = cur[j].first;
}
else{
nxt.back().second++;
add[nxt.back().first].push_back(i);
k--;
use++;
nxt.push_back(cur[j]);
}
}
else{
nxt.push_back(cur[j]);
}
}
if(nxt.back().second==i){
nxt.back().second++;
add[nxt.back().first].push_back(i);
k--;
use++;
}
cur = nxt;
}
for(int i = 0; i<n; i++){
if(i>0){
cout << " ";
}
cout << li[i].second;
for(int j = 0; j<add[i].size(); j++){
f(add[i][j]);
}
}
cout << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |