QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639010#9249. Elimination Series Once Moreblue_skyWA 0ms3856kbC++201.7kb2024-10-13 17:38:512024-10-13 17:38:54

Judging History

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

  • [2024-10-13 17:38:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-10-13 17:38:51]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define bug(X) cout << "bug:# " << X << endl
#define bug2(f, X) cout << "bug:# " << f << " " << X << endl
#define bug3(i, j, G) cout << "bug:# " << i << ' ' << j << ' ' << G << endl
#define endl '\n'
using namespace std;
const int mod = 1e11 + 3;
const int N = 10 + 5e5;
void _();
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        _();
    return 0;
}

int mi(int n)
{
    return 1ll << n;
}
struct Node
{
    int x, idx, res;
};
int get(int n)
{
    int k = 0;
    while (n)
        n >>= 1, k++;
    return k;
}
void _()
{
    int n, k;
    cin >> n >> k;
    vector<int> tr(mi(2 * n));
    vector<Node> a(mi(n));
    for (int i = 1; i <= mi(n); i++)
    {
        cin >> a[i - 1].x;
        a[i - 1].idx = i;
    }
    sort(a.begin(), a.end(), [](Node &a, Node &b)
         { return a.x < b.x; });
    int sum_ceng = get(n);
    auto to_d = [&](int n)
    {
        return sum_ceng - get(n) + 1;
    };
    auto need = [&](int n)
    {
        int t = to_d(n);
        return mi(t) - 1;
    };
    for (auto &[x, idx, res] : a)
    {
        int st = idx;
        int win = 0;
        while (st)
        {
            if (tr[st] + min(k, idx - 1 - tr[st]) >= need(st))
                win = to_d(st);
            st >>= 1;
        }
        res = win;
        st = idx;
        while (st)
        {
            tr[st]++;
            st >>= 1;
        }
    }
    sort(a.begin(), a.end(), [](Node &a, Node &b)
         { return a.idx < b.idx; });
    for (auto [a, b, c] : a)
        cout << c << ' ';
    cout << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

2 1
1 2 3 4

output:

0 1 1 2 

result:

ok 4 number(s): "0 1 1 2"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3856kb

input:

3 5
2 4 7 5 3 8 6 1

output:

0 1 1 2 2 2 2 2 

result:

wrong answer 1st numbers differ - expected: '1', found: '0'