Submission #843189

#TimeUsernameProblemLanguageResultExecution timeMemory
843189Elvin_FritlZalmoxis (BOI18_zalmoxis)C++17
35 / 100
1057 ms58324 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 66; vector<int> v[N] , a(N); void func(int x , int k){ if(k == 0 || x == 0){ cout<<x<<" "; return; } k--; func(x-1 ,k); func(x-1 ,k); } int32_t main() { int n,k; cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i]; } a[n] = 30; int cem = 0; for(int i = 0; i < n; i++){ cem += (1<<a[i]); while(__builtin_ctz(cem) < a[i+1]){ v[i].push_back(__builtin_ctz(cem)); cem += (cem & -cem); k--; } } for(int i=0;i<n;i++){ cout << a[i] << " "; for(int x : v[i]){ func(x, k); } } } /* 1 1 2 2 3 3 4 4 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...