QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#125451 | #92. Santa Claus | Qwerty1232# | Compile Error | / | / | C++17 | 3.6kb | 2023-07-16 18:29:00 | 2024-07-04 00:44:29 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 00:44:29]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-16 18:29:00]
- 提交
answer
#pragma GCC optimize("O3")
#pragma GCC target("avx512vl,avx512dq,avx512bw")
#include <bits/stdc++.h>
void solve() {
int n;
std::cin >> n;
std::vector<int> x(n), h(n), v(n);
for (int i = 0; i < n; i++) {
std::cin >> x[i];
}
for (int i = 0; i < n; i++) {
std::cin >> h[i];
}
for (int i = 0; i < n; i++) {
std::cin >> v[i];
}
int it = h.rend() - std::find(h.rbegin(), h.rend(), 0) - 1;
if (it == -1) {
assert(false);
for (int i = 0; i < n; i++) {
std::cout << x[i] << " \n"[i == n - 1];
}
return;
}
std::vector<int> ans(n, -1);
std::deque<int> cum, fuck;
for (int i = 0; i <= it; i++) {
if (h[i] == 0) {
cum.push_back(v[i]);
} else {
fuck.push_back(v[i]);
}
}
while (it < n - 1 && cum.size() > fuck.size()) {
it++;
fuck.push_back(v[it]);
}
std::sort(fuck.begin(), fuck.end());
std::sort(cum.begin(), cum.end());
// assert(fuck.size() >= cum.size());
// fuck.resize(cum.size());
int x_left = -1;
int left = 0;
std::multiset<int> set;
for (int i = it; i < n; i++) {
if (i != it) {
assert(h[i] == 1);
auto it = std::lower_bound(fuck.begin(), fuck.end(), v[i]);
fuck.insert(it, v[i]);
// fuck.resize(cum.size());
}
if (x_left != left && fuck.size() >= cum.size()) {
int cnt = 0;
for (int i = 0; i < cum.size() && cnt == i; i++) {
cnt += fuck[i] <= cum[i];
}
if (cnt == cum.size()) {
x_left = left;
}
}
while (x_left == left && fuck.size() >= cum.size() && left < i) {
if (h[left] == 0) {
set.insert(v[left]);
left++;
x_left++;
continue;
}
int val_ch = v[left];
int it = std::lower_bound(fuck.begin(), fuck.end(), val_ch) - fuck.begin();
fuck.erase(fuck.begin() + it);
left++;
// std::pair<int, int> min(1.1e9, -1);
// for (int i = 0; i < left; i++) {
// if (h[i] == 0 && v[i] >= val_ch) {
// min = std::min(min, {v[i], i});
// }
// }
auto it1 = set.lower_bound(val_ch);
if (it1 == set.end()) {
if (it >= cum.size()) {
x_left = left;
continue;
}
if (fuck.size() >= cum.size()) {
int cnt = 0;
for (int i = 0; i < cum.size() && cnt == i; i++) {
cnt += fuck[i] <= cum[i];
}
if (cnt == cum.size()) {
x_left = left;
continue;
}
}
break;
} else {
// v[min.second] = -1;
auto it = std::lower_bound(cum.begin(), cum.end(), *it1);
cum.erase(it);
set.erase(it1);
x_left = left;
}
}
if (x_left != -1) {
ans[i] = x[i] * 2 - x[x_left];
}
}
for (int i = 0; i < n; i++) {
std::cout << ans[i] << " \n"[i == n - 1];
}
}
int32_t main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:3: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Deque_base<int, std::allocator<int> >::_Deque_impl::~_Deque_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/deque:66, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:139: /usr/include/c++/13/bits/stl_deque.h:542:14: note: called from here 542 | struct _Deque_impl | ^~~~~~~~~~~