QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#395083#7108. Couleurucup-team055#Compile Error//C++232.5kb2024-04-21 03:24:292024-04-21 03:24:29

Judging History

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

  • [2024-04-21 03:24:29]
  • 评测
  • [2024-04-21 03:24:29]
  • 提交

answer

#include <bits/extc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
const ll INF = LLONG_MAX / 4;
#define rep(i, a, b) for(ll i = a; i < (b); i++)
#define sz(a) ssize(a)
bool chmin(auto& a, auto b) { if(a <= b) return 0; a = b; return 1; }
bool chmax(auto& a, auto b) { if(a >= b) return 0; a = b; return 1; }

using namespace __gnu_pbds;
template<class T> using pbds_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
struct T {
    pbds_set<ll> s;
    ll cost = 0;
    T(const T&) = default;
    T(T&&) = default;
    void push_back(ll x) {
        cost += sz(s) - s.order_of_key(x);
        s.insert(x);
    }
    void pop_back(ll x) {
        s.erase(x);
        cost -= sz(s) - s.order_of_key(x);
    }
    void pop_front(ll x) {
        s.erase(x);
        cost -= s.order_of_key(x);
    }
};
void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N), P(N);
    for(ll& a : A) cin >> a;
    {
        vector<ll> idx(N);
        rep(i, 0, N) idx[i] = i;
        ranges::stable_sort(idx, {}, [&](ll i) { return A[i]; });
        rep(i, 0, N) A[idx[i]] = i;
    }
    for(ll& a : P) cin >> a;
    map<ll, ll> interval;
    multiset<ll> costs {0};
    vector<T> cc(N);
    auto add = [&](ll l, ll r, T t) {
        if(l > r) return;
        interval.emplace(l, r);
        costs.insert(t.cost);
        cc[l] = move(t);
    };
    auto push = [&](ll l, ll r) {
        if(l > r) return;
        interval[l] = r;
        T t;
        rep(i, l, r + 1) t.push_back(A[i]);
        add(l, r, move(t));
    };
    auto rem = [&](ll l, ll r) {
        auto& t = cc[l];
        interval.erase(l);
        costs.erase(costs.find(t.cost));
    };
    auto erase = [&](ll i) {
        auto p = --interval.upper_bound(i);
        auto [l, r] = *p;
        T& t = cc[l];
        rem(l, r);
        if(r - i < i - l) {
            for(ll j = r; j >= i; j--) t.pop_back(A[j]);
            add(l, i - 1, move(t));
            push(i + 1, r);
        }
        else {
            rep(j, l, i + 1) t.pop_front(A[j]);
            add(i + 1, r, move(t));
            push(l, i - 1);
        }
    };
    push(0, N - 1);
    vector<ll> ans;
    ll prev = 0;
    for(ll p : P) {
        prev = *rbegin(costs);
        ans.push_back(prev);
        p ^= prev;
        p--;
        erase(p);
    }
    rep(i, 0, N) cout << ans[i] << " \n"[i + 1 == N];
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    ll T;
    cin >> T;
    while(T--) solve();
}

Details

answer.code: In lambda function:
answer.code:50:23: error: use of deleted function ‘T& T::operator=(const T&)’
   50 |         cc[l] = move(t);
      |                       ^
answer.code:13:8: note: ‘T& T::operator=(const T&)’ is implicitly declared as deleted because ‘T’ declares a move constructor or move assignment operator
   13 | struct T {
      |        ^
answer.code: In lambda function:
answer.code:55:11: error: no matching function for call to ‘T::T()’
   55 |         T t;
      |           ^
answer.code:17:5: note: candidate: ‘T::T(T&&)’
   17 |     T(T&&) = default;
      |     ^
answer.code:17:5: note:   candidate expects 1 argument, 0 provided
answer.code:16:5: note: candidate: ‘T::T(const T&)’
   16 |     T(const T&) = default;
      |     ^
answer.code:16:5: note:   candidate expects 1 argument, 0 provided
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,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/extc++.h:32,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = T; _Args = {}]’:
/usr/include/c++/13/bits/stl_uninitialized.h:643:18:   required from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = T*; _Size = long unsigned int; bool _TrivialValueType = false]’
/usr/include/c++/13/bits/stl_uninitialized.h:706:20:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = T*; _Size = long unsigned int]’
/usr/include/c++/13/bits/stl_uninitialized.h:773:44:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = T*; _Size = long unsigned int; _Tp = T]’
/usr/include/c++/13/bits/stl_vector.h:1715:36:   required from ‘constexpr void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = T; _Alloc = std::allocator<T>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_vector.h:555:9:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = T; _Alloc = std::allocator<T>; size_type = long unsigned int; allocator_type = std::allocator<T>]’
answer.code:45:19:   required from here
/usr/include/c++/13/bits/stl_construct.h:115:28: error: no matching function for call to ‘construct_at(T*&)’
  115 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_construct.h:94:5: note: candidate: ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)’
   94 |     construct_at(_Tp* __location, _Args&&... __args)
      |     ^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_construct.h:94:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_construct.h: In substitution of ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = T; _Args = {}]’:
/usr/include/c++/13/bits/stl_construct.h:115:21:   required from ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = T; _Args = {}]’
/usr/include/c++/13/bits/stl_uninitialized.h:643:18:   required from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = T*; _Size = long unsigned int; bool _TrivialValueType = false]’
/usr/include/c++/13/bits/stl_uninitialized.h:706:20:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = T*; _Size = long unsigned int]’
/usr/include/c++/13/bits/stl_uninitialized.h:773:44:   required from ‘constexpr _ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = T*; _Size = long unsigned int; _Tp = T]’
/usr/include/c++/13/bits/stl_vector.h:1715:36:   required from ‘constexpr void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = T; _Alloc = std::allocator<T>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_vector.h:555:9:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = T; _Alloc = std::allocator<T>; size_type = long unsigned int; allocator_type = std::allocator<T>]’
answer.code:45:19:   required from here
/usr/include/c++/13/bits/stl_construct.h:96:17: error: no matching function for call to ‘T::T()’
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |           ...