QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#125461 | #92. Santa Claus | Qwerty1232# | Compile Error | / | / | C++17 | 4.1kb | 2023-07-16 18:37:17 | 2024-07-04 00:44:31 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 00:44:31]
- 评测
- 测评结果: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:37:17]
- 提交
answer
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx512vl,avx512dq,avx512bw")
#include <cassert>
#include <iostream>
void* operator new(size_t s) {
constexpr static int MEM = 1e8;
static char data[MEM];
static size_t ptr = 0;
ptr += s;
assert(ptr <= MEM);
return data + ptr - s;
}
void operator delete(void*) { ; }
#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];
}
if (n - std::accumulate(h.begin(), h.end(), 0) > n / 2) {
for (int i = 0; i < n; i++) {
std::cout << -1 << " \n"[i == n - 1];
}
return;
}
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::vector<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(); 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(); 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/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from answer.code:4: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_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/vector:66, from /usr/include/c++/13/functional:64, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53, from answer.code:15: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~