제출 #1324199

#제출 시각아이디문제언어결과실행 시간메모리
1324199nikaa123Nile (IOI24_nile)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "nile.h"
using namespace std;

vector<long long> calculate_costs(vector<int> W, vector<int> A,
                                      vector<int> B, vector<int> E) {
  int N = W.size();
  int Q = (int)E.size();
  vector <array<int,3>> arr;
  for (int i = 0; i < N; i++) {
    arr.emplace_back(W[i],A[i],B[i]);
  }
  sort(arr.begin(),arr.end());
  vector <int> c(N);
  for (int i = 0; i < N; i++) {
    c[i] = A[i]-B[i];
  }
  vector <array<int,3>> lst;
  for (int i = 0; i < N-1; i++) {
    lst.emplace_back(arr[i+1][0] - arr[i][0],-1,i);
    if (i+2 < N) lst.emplace_back(arr[i+2][0] - arr[i][0],-2,i);
  }
  for (int i = 0; i < Q; i++) {
    lst.emplace_back(E[i],0,i);
  }
  sort(lst.begin(),lst.end());

  //dsu
  int ans = 0;;
  vector <int> par(N);
  vector <int> bsum(N);
  vector <int> sz(N);
  vector <int> l(N);
  vector <array<int,2>> mn(N);
  vector <int> mn1(N);
  for (int i = 0; i < N; i++) {
    ans += arr[i][2];
    l[i] = i;
    par[i] = i;
    bsum[i] = arr[i][2];
    sz[i] = 1;
    mn[i][0] = mn[i][1] = INT_MAX;
    mn[i][i&1] = c[i]; 
    mn1[i] = INT_MAX;
  }

  function<int(int)> getpar = [&](int x) {
    if (x == par[x]) return x;
    return par[x] = getpar(par[x]);
  };

  auto getans = [&](int x) {
    return (bsum[x] + (sz[x]&1 ? min(mn1[x],mn[x][l[x]&1]):0));
  }; 

  auto unionset = [&](int a, int b) {
    a = getpar(a);
    b = getpar(b);
    if (a == b) return;
    ans -= getans(a);
    ans -= getans(b);
    sz[a] += sz[b];
    mn[a] = min(mn[a],mn[b]);
    l[a] = min(l[a],l[b]);
    par[b] = a;
    bsum[a] += bsum[b];
    mn1[a] = min(mn1[a],mn1[b]);
    mn[a][0] = min(mn[a][0],mn[b][0]);
    mn[a][1] = min(mn[a][1],mn[b][1]);
    ans += getans(a);
  };

  vector<long long> R(Q, 0);
  for (auto cur:lst) {
    if (cur[1] == 0) R[cur[2]] = ans;
    if (cur[1] == -1) {
      unionset(cur[2],cur[2]+1);
    }
    if (cur[1] == -2) {
      int x = getpar(cur[2]);
      ans -= getans(x);
      mn1[x] = min(mn1[x],c[cur[2]+1]);
      ans += getans(x); 
    }
  }
  return R;
}

컴파일 시 표준 에러 (stderr) 메시지

In file included from /usr/include/c++/13/ext/alloc_traits.h:34,
                 from /usr/include/c++/13/bits/basic_string.h:39,
                 from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from nile.cpp:1:
/usr/include/c++/13/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]':
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:11:21:   required from here
/usr/include/c++/13/bits/alloc_traits.h:540:28: error: no matching function for call to 'construct_at(std::array<int, 3>*&, int&, int&, int&)'
  540 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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 = std::array<int, 3>; _Args = {int&, int&, int&}]':
/usr/include/c++/13/bits/alloc_traits.h:540:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]'
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:11:21:   required from here
/usr/include/c++/13/bits/stl_construct.h:96:17: error: array must be initialized with a brace-enclosed initializer
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int, int, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]':
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:20:21:   required from here
/usr/include/c++/13/bits/alloc_traits.h:540:28: error: no matching function for call to 'construct_at(std::array<int, 3>*&, int, int, int&)'
  540 |           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 = std::array<int, 3>; _Args = {int, int, int&}]':
/usr/include/c++/13/bits/alloc_traits.h:540:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int, int, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]'
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:20:21:   required from here
/usr/include/c++/13/bits/stl_construct.h:96:17: error: array must be initialized with a brace-enclosed initializer
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]':
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:24:21:   required from here
/usr/include/c++/13/bits/alloc_traits.h:540:28: error: no matching function for call to 'construct_at(std::array<int, 3>*&, int&, int, int&)'
  540 |           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 = std::array<int, 3>; _Args = {int&, int, int&}]':
/usr/include/c++/13/bits/alloc_traits.h:540:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int, int&}; _Tp = std::array<int, 3>; allocator_type = std::allocator<std::array<int, 3> >]'
/usr/include/c++/13/bits/vector.tcc:117:30:   required from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&]'
nile.cpp:24:21:   required from here
/usr/include/c++/13/bits/stl_construct.h:96:17: error: array must be initialized with a brace-enclosed initializer
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~