QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#629218#9249. Elimination Series Once MoreyouthpaulWA 1ms3608kbC++201.3kb2024-10-11 09:13:242024-10-11 09:13:25

Judging History

你现在查看的是最新测评结果

  • [2024-10-11 09:13:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-10-11 09:13:24]
  • 提交

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'