제출 #1167270

#제출 시각아이디문제언어결과실행 시간메모리
1167270adriannokRainforest Jumps (APIO21_jumps)C++20
컴파일 에러
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; int N; vector<int> H; vector<int> sorted; vector< unordered_map<int, int> > d; unordered_map<int, int> id; void washifloi_Init() { for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) if( d[i].count(k) && d[k].count(i) ) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } void verify(const int& i, const int& j, int &in) { if(H[j] > H[i] && H[j] < (in<N? H[in] : N+1)) in = j; } void init(int n, vector<int> h) { N = n; H = h; d.assign( N, vector<int>(N, N+1) ); for (int i = 0; i < n; ++i) { int in = N+1; for (int j = i+1; j < n; ++j) { verify(i, j, in); } if(in < N) d[i][in] = 1; in = N+1; for (int j = i-1; j >= 0; --j) { verify(i, j, in); } if(in < N) d[i][in] = 1; } washifloi_Init(); } int minimum_jumps(int A, int B, int C, int D) { int minJ = N+1; for(int i = A; i <= B; ++i) for(int j = C; j <= D; ++j) { minJ = min(minJ, d[i][j]); } if(minJ == N+1) minJ = -1; return minJ; }

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

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:32:17: error: no matching function for call to 'std::vector<std::unordered_map<int, int> >::assign(int&, std::vector<int>)'
   32 |         d.assign( N, vector<int>(N, N+1) );
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:768:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::unordered_map<int, int>; _Alloc = std::allocator<std::unordered_map<int, int> >]'
  768 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:768:9: note:   template argument deduction/substitution failed:
jumps.cpp:32:17: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
   32 |         d.assign( N, vector<int>(N, N+1) );
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::unordered_map<int, int>; _Alloc = std::allocator<std::unordered_map<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::unordered_map<int, int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:749:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const std::unordered_map<int, int>&'}
  749 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/11/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::unordered_map<int, int>; _Alloc = std::allocator<std::unordered_map<int, int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:794:7: note:   candidate expects 1 argument, 2 provided