QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859786#9915. General Symmetryucup-team6275RE 0ms3712kbC++202.2kb2025-01-17 23:35:082025-01-17 23:35:19

Judging History

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

  • [2025-01-17 23:35:19]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3712kb
  • [2025-01-17 23:35:08]
  • 提交

answer

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <deque>
#include <set>
#include <random>
#include <cassert>
#include <chrono>
#include <bitset>

using namespace std;
const int MAXN = 2e2 + 10;
const int MAXA = 10;

bitset<MAXN> bad_pos[MAXA];

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; --a[i];
    }
    vector <int> ans(2 * n - 1);
    for (int val = 0; val < MAXA; ++val) {
        for (int i = 0; i < n; ++i) {
            if (abs(a[i] - val) > k) bad_pos[val].set(i);
        }
    }

    bitset<MAXN> cur_positions;
    bitset<MAXN> tmp;
    for (int i = 0; i < n; ++i) {
        ans[2 * i] = 2 * min(i + 1, n - i) - 1;
    }
    for (int i = 0; i < n - 1; ++i) {
        ans[2 * i + 1] = 2 * min(i + 1, n - i - 1);
    }

    auto my_find_first = [&](const bitset<MAXN>& x) {
        for (int i = 0; i < MAXN; ++i) {
            if (x[i]) return i;
        }
        return MAXN;
    };

    auto my_find_next = [&](const bitset<MAXN>& x, int j) {
        for (int i = j + 1; i < MAXN; ++i) {
            if (x[i]) return i;
        }
        return MAXN;
    };

    for (int r = 0; r < n; ++r) {
        cur_positions.set(r);
        if (r) cur_positions.set(r - 1);

        tmp = cur_positions & bad_pos[a[r]];
#ifndef LOCAL
        int cha = tmp._Find_first();
#else
        int cha = my_find_first(tmp);
#endif

        while (cha != MAXN) {
            ans[cha + r] = r - cha - 1;
            cur_positions.reset(cha);
#ifndef LOCAL
            cha = tmp._Find_next(cha);
#else
            cha = my_find_next(tmp, cha);
#endif
        }

        cur_positions >>= 1;
    }

    for (int i = 0; i < n; ++i) cout << ans[2 * i] << " ";
    for (int i = 0; i < n - 1; ++i) cout << ans[2 * i + 1] << " ";
}

signed main() {
    if (1) {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
    }
    int t = 1;
    while (t--) {
        solve();
    }

    return 0;
}

/*
5 7
1 2
1 3
2 4
2 5
A 1 4 2
A 3 5 2
D 1 4
D 2 3
D 2 1
A 5 5 10
D 5 100
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 0
1 2 1 2 1

output:

1 3 5 3 1 0 0 0 0 

result:

ok 9 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5 1
1 2 1 3 1

output:

1 3 5 3 1 2 2 0 0 

result:

ok 9 numbers

Test #3:

score: -100
Runtime Error

input:

10 0
1 2 3 4 500 5 501 6 499 503

output:


result: