제출 #1275275

#제출 시각아이디문제언어결과실행 시간메모리
1275275zuz14Wall (IOI14_wall)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; const int N=(1<<20); //sprawdzic pair<int, int> tree[2*N+7]; //lower, upper void Push(int w){ tree[2*w].F=max(tree[2*w].F, tree[w].F); tree[2*w].S=min(tree[2*w].S, tree[w].S); tree[2*w+1].F=max(tree[2*w+1].F, tree[w].F); tree[2*w+1].S=min(tree[2*w+1].S, tree[w].S); } void Update(int w, int b, int e, int l, int r, int h, bool num){ if (l>e && r<b) return; if (l>=b && r<=e){ if (num) { tree[w].F=max(tree[w].F, h); tree[w].S=max(tree[w].S, h); } else { tree[w].F=min(tree[w].F, h); tree[w].S=min(tree[w].S, h); } } Push(w); Update(2*w, b, e, l, (l+r)/2, h, num); Update(2*w+1, b, e, (l+r)/2, r, h, num); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ fill(tree, tree+2*N+1, 0); for (int i=0; i<k; i++) Update(1, left[i], right[i], 0, N-1, height[i], op[i]-1); for (int i=1; i<N; i++) Push(i); copy(tree+N, tree+N+n, finalHeight); }

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

In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from wall.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h: In instantiation of 'constexpr typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<int, int>*; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/13/bits/stl_algobase.h:977:21:   required from 'constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = pair<int, int>*; _Tp = int]'
/usr/include/c++/13/bits/stl_algobase.h:1007:20:   required from 'constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<int, int>*; _Tp = int]'
wall.cpp:35:9:   required from here
/usr/include/c++/13/bits/stl_algobase.h:931:18: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'const int')
  931 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64:
/usr/include/c++/13/bits/stl_pair.h:439:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) requires  _S_assignable<const _U1&, const _U2&>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  439 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:439:9: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_algobase.h:931:18: note:   mismatched types 'const std::pair<_T1, _T2>' and 'const int'
  931 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
/usr/include/c++/13/bits/stl_pair.h:451:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) requires  _S_assignable<_U1, _U2>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  451 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:451:9: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_algobase.h:931:18: note:   mismatched types 'std::pair<_T1, _T2>' and 'const int'
  931 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
/usr/include/c++/13/bits/stl_pair.h:416:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_T1, _T2>&) requires  _S_assignable<const _T1&, const _T2&>() [with _T1 = int; _T2 = int]'
  416 |       operator=(const pair& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:416:29: note:   no known conversion for argument 1 from 'const int' to 'const std::pair<int, int>&'
  416 |       operator=(const pair& __p)
      |                 ~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_pair.h:427:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_T1, _T2>&&) requires  _S_assignable<_T1, _T2>() [with _T1 = int; _T2 = int]'
  427 |       operator=(pair&& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:427:24: note:   no known conversion for argument 1 from 'const int' to 'std::pair<int, int>&&'
  427 |       operator=(pair&& __p)
      |                 ~~~~~~~^~~
/usr/include/c++/13/bits/stl_algobase.h: In instantiation of 'static constexpr _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = std::pair<int, int>*; _OI = int*]':
/usr/include/c++/13/bits/stl_algobase.h:503:12:   required from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = pair<int, int>*; _OI = int*]'
/usr/include/c++/13/bits/stl_algobase.h:533:42:   required from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = pair<int, int>*; _OI = int*]'
/usr/include/c++/13/bits/stl_algobase.h:541:31:   required from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = pair<int, int>*; _OI = int*]'
/usr/include/c++/13/bits/stl_algobase.h:633:7:   required from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = pair<int, int>*; _OI = int*]'
wall.cpp:40:9:   required from here
/usr/include/c++/13/bits/stl_algobase.h:388:25: error: cannot convert 'std::pair<int, int>' to 'int' in assignment
  388 |               *__result = *__first;
      |               ~~~~~~~~~~^~~~~~~~~~