제출 #1251479

#제출 시각아이디문제언어결과실행 시간메모리
1251479raysh07송신탑 (IOI22_towers)C++17
컴파일 에러
0 ms0 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; #define int long long #define INF (int)1e18 int n; vector <int> a; void init(int32_t N, vector<int32_t> H) { n = N; a = H; } int32_t max_towers(int32_t l, int32_t r, int32_t d) { int ans = 1; int best = INF; int mx = -INF; for (int i = l; i <= r; i++){ if (max(a[i], best) + d <= mx){ ans++; best = a[i]; mx = -INF; } else { best = min(best, a[i]); mx = max(mx, a[i]); } } return (int32_t)ans; }

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

towers.cpp: In function 'void init(int32_t, std::vector<int>)':
towers.cpp:12:9: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   12 |     a = H;
      |         ^
In file included from /usr/include/c++/11/vector:72,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~