QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#859776 | #9915. General Symmetry | ucup-team6275 | WA | 0ms | 26596kb | C++20 | 1.7kb | 2025-01-17 23:19:17 | 2025-01-17 23:19:18 |
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 = 2e5 + 10;
const int MAXA = 1000;
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);
}
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]];
int cha = tmp._Find_first();
while (cha != MAXN) {
ans[cha + r] = r - cha - 1;
cur_positions.reset(cha);
cha = tmp._Find_next(cha);
}
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: 24948kb
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: -100
Wrong Answer
time: 0ms
memory: 26596kb
input:
5 1 1 2 1 3 1
output:
1 3 5 3 1 2 4 0 0
result:
wrong answer 7th numbers differ - expected: '2', found: '4'