QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859786 | #9915. General Symmetry | ucup-team6275 | RE | 0ms | 3712kb | C++20 | 2.2kb | 2025-01-17 23:35:08 | 2025-01-17 23:35:19 |
Judging History
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
*/
詳細信息
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