QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449854#8598. AND Масивbashkort#Compile Error//C++202.2kb2024-06-21 18:20:492024-06-21 18:20:49

Judging History

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

  • [2024-06-21 18:20:49]
  • 评测
  • [2024-06-21 18:20:49]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, b;
    cin >> n >> b;

    vector<int> a(n);
    vector<ll> suf(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) {
            suf[i] += (i + 1);
        }
    }
    for (int i = n - 1; i >= 0; --i) {
        suf[i] += suf[i + 1];
    }

    vector<ll> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[i] += b * suf[i];
    }
    const int nb = 1 << b;
    vector stk(nb, gp_hash_table<int, int>{});
    vector<int> value(n * b), timer(n * b);
    int l = b / 3, r = b - l;
    int nl = (1 << l), nr = (1 << r);

    auto insert = [&](int id, int mod) {
        int x = value[id];
        int lx = x & (nl - 1);
        int ix = lx;
        int rx = x >> l << l;
        while (true) {
            if (mod == 1) {
                stk[lx + rx][id] = 0;
            } else {
                stk[lx + rx].erase(id);
            }
            if (lx + 1 == nl) {
                break;
            }
            lx = (lx + 1) | ix;
        }
    };

    auto update = [&](int x, int add, int orz) {
        vector<int> now;
        int lx = x & (nl - 1);
        int rx = x >> l;
        int ix = rx;
        while (true) {
            int f = lx + (rx << l);
            now.insert(now.end(), stk[f].begin(), stk[f].end());
            stk[f].clear();
            if (rx == 0) {
                break;
            }
            rx = (rx - 1) & ix;
        }
        for (int i : now) {
            insert(i, -1);
            value[i] |= orz;
            ans[i % n] += add;
            insert(i, 1);
        }
    };

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < b; ++j) {
            value[j * n + i] = 1 << j;
            insert(j * n + i, 1);
        }
        if (a[i] != 0) {
            update(nb - 1 - a[i], i + 1, a[i]);
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << " \n"[i == n - 1];
    }

    return 0;
}

Details

In file included from /usr/include/c++/13/vector:65,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_uninitialized.h: In instantiation of ‘constexpr bool std::__check_constructible() [with _ValueType = int; _Tp = pair<const int, int>&]’:
/usr/include/c++/13/bits/stl_uninitialized.h:182:4:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_pbds::detail::gp_ht_map<int, int, tr1::hash<int>, equal_to<int>, allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; _ForwardIterator = int*]’
/usr/include/c++/13/bits/stl_uninitialized.h:373:37:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_pbds::detail::gp_ht_map<int, int, tr1::hash<int>, equal_to<int>, allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; _ForwardIterator = int*; _Tp = int]’
/usr/include/c++/13/bits/vector.tcc:781:34:   required from ‘constexpr void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = __gnu_pbds::detail::gp_ht_map<int, int, std::tr1::hash<int>, std::equal_to<int>, std::allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator]’
/usr/include/c++/13/bits/stl_vector.h:1483:19:   required from ‘constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with _InputIterator = __gnu_pbds::detail::gp_ht_map<int, int, std::tr1::hash<int>, std::equal_to<int>, std::allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; <template-parameter-2-2> = void; _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]’
answer.code:63:23:   required from here
/usr/include/c++/13/bits/stl_uninitialized.h:90:56: error: static assertion failed: result type must be constructible from input type
   90 |       static_assert(is_constructible<_ValueType, _Tp>::value,
      |                                                        ^~~~~
/usr/include/c++/13/bits/stl_uninitialized.h:90:56: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
In file included from /usr/include/c++/13/bits/stl_iterator.h:85,
                 from /usr/include/c++/13/bits/stl_algobase.h:67,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = int; _Args = {pair<const int, int>&}]’:
/usr/include/c++/13/bits/stl_uninitialized.h:120:21:   required from ‘constexpr _ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_pbds::detail::gp_ht_map<int, int, tr1::hash<int>, equal_to<int>, allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; _ForwardIterator = int*]’
/usr/include/c++/13/bits/stl_uninitialized.h:371:30:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_pbds::detail::gp_ht_map<int, int, tr1::hash<int>, equal_to<int>, allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::iterator_; _ForwardIterator = int...