QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140630#1140. Distributing CandiesQwerty1232#Compile Error//C++201.1kb2023-08-16 15:00:092024-07-04 02:37:54

Judging History

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

  • [2024-07-04 02:37:54]
  • 评测
  • [2023-08-16 15:00:09]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC target("avx512f,avx512vl,avx512dq,avx512bw")
#include "candies.h"

#include <functional>
#include <vector>

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> L, std::vector<int> R, std::vector<int> V) {
    int n = c.size();
    int q = L.size();

    std::vector<int> s(n);
    int cnt = std::count_if(V.begin(), V.end(), [&](auto a) { return a > 0; });
    bool rev = false;
    if (cnt > q / 2) {
        rev = true;
        s = c;
        for (int i = 0; i < q; i++) {
            V[i] *= -1;
        }
    }
    for (int i = 0; i < q; i++) {
        int l = L[i], r = R[i], dlt = V[i];
        r++;
        if (dlt < 0) {
            for (int j = l; j < r; j++) {
                s[j] = std::max(0, s[j] + dlt);
            }
        } else {
            for (int j = l; j < r; j++) {
                s[j] = std::min(c[j], s[j] + dlt);
            }
        }
    }

    if (rev) {
        for (int i = 0; i < n; i++) {
            s[i] = c[i] - s[i];
        }
    }

    return s;
}

Details

In file included from /usr/include/c++/13/vector:63,
                 from candies.h:1,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr 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’ ‘constexpr 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:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~