QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#125455#92. Santa ClausQwerty1232#Compile Error//C++173.6kb2023-07-16 18:32:252024-07-04 00:44:30

Judging History

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

  • [2024-07-04 00:44:30]
  • 评测
  • [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:32:25]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#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::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/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::_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:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~