제출 #425795

#제출 시각아이디문제언어결과실행 시간메모리
425795Hazem전선 연결 (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; #define LL long long const LL INF = 1e9; const LL LINF = 1e18; const int N = 2e3+10; LL dp[N][N][2][2]; LL n,m; vector<LL>R,B; LL solve(int i,int j,int t1,int t2){ if(i==n-1&&j==m-1&&t1&&t2) return 0; if(dp[i][j][t1][t2]!=-1) return dp[i][j][t1][t2]; dp[i][j][t1][t2] = LINF; if(t1&&i<n-1) dp[i][j][t1][t2] = min(dp[i][j][t1][t2],solve(i+1,j,0,t2)); if(t2&&j<m-1) dp[i][j][t1][t2] = min(dp[i][j][t1][t2],solve(i,j+1,t1,0)); dp[i][j][t1][t2] = min(dp[i][j][t1][t2],solve(i,j,1,1)+abs(R[i]-B[j])); return dp[i][j][t1][t2]; } long long min_total_length(std::vector<int> r, std::vector<int> b) { n = r.size(),m = b.size(); R = r;B = b; LL ret = 0; for(LL i=0;i<n-1;i++) ret += (R[i+1]-R[i])*(i+1); for(LL i=m-1;i>=1;i--) ret += (B[i]-B[i-1])*(m-i); ret += (B[0]-R[n-1])*min(n,m); if(n>m) for(int i=n-1;i>=m;i--) ret += B[0]-R[i]; if(m>n) for(int i=0;i<m-n;i++) ret += B[i]-R[n-1]; return ret; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:37:6: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   37 |  R = r;B = b;
      |      ^
In file included from /usr/include/c++/10/vector:72,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/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++/10/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++/10/vector:67,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/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++/10/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++/10/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++/10/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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
wiring.cpp:37:12: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   37 |  R = r;B = b;
      |            ^
In file included from /usr/include/c++/10/vector:72,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/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++/10/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++/10/vector:67,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/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++/10/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++/10/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++/10/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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~