# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850947 | 2023-09-18T02:00:46 Z | Charizard2021 | Zalmoxis (BOI18_zalmoxis) | C++17 | 195 ms | 39892 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1000001; void solve(int n, int &k){ if(k == 0){ cout << n << " "; return; } k--; solve(n - 1, k); solve(n - 1, k); } int main(){ int n, k; cin >> n >> k; int a[1 + n]; for(int i = 0; i < n; i++){ cin >> a[i]; } a[n] = 30; int counter = 0; vector<int> cur[1 + n]; for(int i = 0; i < n; i++){ counter += (1 << a[i]); while(__builtin_ctz(counter) < a[i + 1]){ cur[i].push_back(__builtin_ctz(counter)); counter += (counter & (-counter)); k--; } } for(int i = 0;i < n; i++){ cout << a[i] << " "; for(int j = 0; j < cur[i].size(); j++){ solve(cur[i][j], k); } } cout << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 178 ms | 31824 KB | Output is correct |
2 | Correct | 185 ms | 31924 KB | Output is correct |
3 | Correct | 181 ms | 31824 KB | Output is correct |
4 | Correct | 184 ms | 31828 KB | Output is correct |
5 | Correct | 191 ms | 31736 KB | Output is correct |
6 | Correct | 195 ms | 31824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 181 ms | 31696 KB | Output is correct |
2 | Correct | 183 ms | 31824 KB | Output is correct |
3 | Correct | 191 ms | 32068 KB | Output is correct |
4 | Correct | 185 ms | 31956 KB | Output is correct |
5 | Correct | 181 ms | 31956 KB | Output is correct |
6 | Correct | 184 ms | 31824 KB | Output is correct |
7 | Correct | 190 ms | 31908 KB | Output is correct |
8 | Correct | 182 ms | 31868 KB | Output is correct |
9 | Correct | 171 ms | 31824 KB | Output is correct |
10 | Correct | 120 ms | 34984 KB | Output is correct |
11 | Correct | 139 ms | 33076 KB | Output is correct |
12 | Correct | 91 ms | 39892 KB | Output is correct |
13 | Correct | 90 ms | 39504 KB | Output is correct |
14 | Correct | 92 ms | 39520 KB | Output is correct |