이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// And you curse yourself for things you never done
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
vector<int> v[maxn];
int a[maxn];
void go(int &k, int x){
if(k == 0){
cout << x << " ";
return;
}
if(x == 0){
cout << x << " ";
return;
}
k--;
go(k, x-1);
go(k, x-1);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
int n, k;
cin >> n >> k;
for(int i = 0; i < n; i++){
cin >> a[i];
}
a[n] = 30;
int sm = 0;
for(int i = 0; i < n; i++){
sm+= 1<<a[i];
while(__builtin_ctz(sm) < a[i+1])
v[i].PB(__builtin_ctz(sm)), sm+= sm & -sm, --k;
}
assert(k >= 0);
for(int i = 0; i < n; i++){
cout << a[i] << " ";
for(int x : v[i]){
go(k, x);
}
}
return cout << endl, 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |