QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629218 | #9249. Elimination Series Once More | youthpaul | WA | 1ms | 3608kb | C++20 | 1.3kb | 2024-10-11 09:13:24 | 2024-10-11 09:13:25 |
Judging History
answer
#include<bits/stdc++.h>
#define fore(i,l,r) for(int i=(int)(l);i<(int)(r);++i)
#define fi first
#define se second
#define endl '\n'
#define ull unsigned long long
#define ALL(v) v.begin(), v.end()
#define Debug(x, ed) std::cerr << #x << " = " << x << ed;
const int INF=0x3f3f3f3f;
const long long INFLL=1e18;
typedef long long ll;
const int N = 20;
int cnt[(1 << N) + 50];
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int n, k;
std::cin >> n >> k;
int m = (1 << n);
std::vector<int> a(m + 1);
fore(i, 1, m + 1) std::cin >> a[i];
std::vector<int> ord(m + 1);
fore(i, 1, m + 1) ord[i] = i;
std::sort(ord.begin() + 1, ord.end(), [&](int i, int j){
return a[i] > a[j];
});
std::vector<int> ans(m + 1);
fore(idx, 1, m + 1){
int i = ord[idx];
int h = std::__lg(a[i]);
int t = k;
int u = (1 << n) - 1 + i;
while(h){
int fa = u / 2;
if(t < cnt[fa]) break;
--h;
u = fa;
++ans[i];
}
u = i;
while(u){
++cnt[u];
u /= 2;
}
}
fore(i, 1, m + 1) std::cout << ans[i] << " \n"[i == m];
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
2 1 1 2 3 4
output:
0 1 1 2
result:
ok 4 number(s): "0 1 1 2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
3 5 2 4 7 5 3 8 6 1
output:
1 2 2 2 1 3 2 0
result:
ok 8 numbers
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3556kb
input:
3 0 1 2 7 4 5 8 3 6
output:
0 0 2 0 0 3 1 1
result:
wrong answer 2nd numbers differ - expected: '1', found: '0'