제출 #737438

#제출 시각아이디문제언어결과실행 시간메모리
737438keisuke6도로 폐쇄 (APIO21_roads)C++14
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <vector> #include <algorithm> #include <map> using namespace std; typedef long long ll; vector<vector<pair<int,int>>> G(100100); map<pair<int,bool>,int> m; int bor = 0; int f(int x, int par, bool p){ if(m.count({x,p})) return m[{x,p}]; int ed = p; vector<int> S = {}; for(int y:G[x]){ int u,w; tie(u,w) = y; if(par == u) continue; m[{x,p}] += f(u,x,false)+w; S.push_back(f(u,x,true)-(f(u,x,false)+w)); } sort(S.begin(),S.end()); int now = 0; if(ed > bor) return 1e9; while(ed < bor && now != S.size()){ ed++; m[{x,p}] += S[now]; now++; } return m[{x,p}]; } std::vector<ll> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { for(int i=0;i<W.size();i++){ G[U[i]].push_back({V[i],W[i]}); G[V[i]].push_back({U[i],W[i]}); } vector<int> A = {}; for(int i=0;i<N;i++){ bor = i; m.clear(); A.push_back(f(0,-1,false)); } return A; }

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

roads.cpp: In function 'int f(int, int, bool)':
roads.cpp:15:16: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   15 |   for(int y:G[x]){
      |                ^
roads.cpp:17:16: error: no match for 'operator=' (operand types are 'std::tuple<int&, int&>' and 'int')
   17 |     tie(u,w) = y;
      |                ^
In file included from /usr/include/c++/10/bits/stl_map.h:63,
                 from /usr/include/c++/10/map:61,
                 from roads.cpp:5:
/usr/include/c++/10/tuple:1173:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(typename std::conditional<__assignable<const _T1&, const _T2&>(), const std::tuple<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int&; _T2 = int&; typename std::conditional<__assignable<const _T1&, const _T2&>(), const std::tuple<_T1, _T2>&, const std::__nonesuch&>::type = const std::tuple<int&, int&>&]'
 1173 |       operator=(typename conditional<__assignable<const _T1&, const _T2&>(),
      |       ^~~~~~~~
/usr/include/c++/10/tuple:1175:35: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, const std::tuple<int&, int&>&, const std::__nonesuch&>::type' {aka 'const std::tuple<int&, int&>&'}
 1173 |       operator=(typename conditional<__assignable<const _T1&, const _T2&>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1174 |          const tuple&,
      |          ~~~~~~~~~~~~~             
 1175 |          const __nonesuch&>::type __in)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/10/tuple:1184:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(typename std::conditional<__assignable<_T1, _T2>(), std::tuple<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int&; _T2 = int&; typename std::conditional<__assignable<_T1, _T2>(), std::tuple<_T1, _T2>&&, std::__nonesuch&&>::type = std::tuple<int&, int&>&&]'
 1184 |       operator=(typename conditional<__assignable<_T1, _T2>(),
      |       ^~~~~~~~
/usr/include/c++/10/tuple:1186:30: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, std::tuple<int&, int&>&&, std::__nonesuch&&>::type' {aka 'std::tuple<int&, int&>&&'}
 1184 |       operator=(typename conditional<__assignable<_T1, _T2>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1185 |          tuple&&,
      |          ~~~~~~~~             
 1186 |          __nonesuch&&>::type __in)
      |          ~~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/10/tuple:1196:2: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<__assignable<const _U1&, const _U2&>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::tuple<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int&; _T2 = int&]'
 1196 |  operator=(const tuple<_U1, _U2>& __in)
      |  ^~~~~~~~
/usr/include/c++/10/tuple:1196:2: note:   template argument deduction/substitution failed:
roads.cpp:17:16: note:   mismatched types 'const std::tuple<_T1, _T2>' and 'int'
   17 |     tie(u,w) = y;
      |                ^
In file included from /usr/include/c++/10/bits/stl_map.h:63,
                 from /usr/include/c++/10/map:61,
                 from roads.cpp:5:
/usr/include/c++/10/tuple:1206:2: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<__assignable<_U1, _U2>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::tuple<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int&; _T2 = int&]'
 1206 |  operator=(tuple<_U1, _U2>&& __in)
      |  ^~~~~~~~
/usr/include/c++/10/tuple:1206:2: note:   template argument deduction/substitution failed:
roads.cpp:17:16: note:   mismatched types 'std::tuple<_T1, _T2>' and 'int'
   17 |     tie(u,w) = y;
      |                ^
In file included from /usr/include/c++/10/bits/stl_map.h:63,
                 from /usr/include/c++/10/map:61,
                 from roads.cpp:5:
/usr/include/c++/10/tuple:1216:2: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<__assignable<const _U1&, const _U2&>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int&; _T2 = int&]'
 1216 |  operator=(const pair<_U1, _U2>& __in)
      |  ^~~~~~~~
/usr/include/c++/10/tuple:1216:2: note:   template argument deduction/substitution failed:
roads.cpp:17:16: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   17 |     tie(u,w) = y;
      |                ^
In file included from /usr/include/c++/10/bits/stl_map.h:63,
                 from /usr/include/c++/10/map:61,
                 from roads.cpp:5:
/usr/include/c++/10/tuple:1227:2: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<__assignable<_U1, _U2>(), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int&; _T2 = int&]'
 1227 |  operator=(pair<_U1, _U2>&& __in)
      |  ^~~~~~~~
/usr/include/c++/10/tuple:1227:2: note:   template argument deduction/substitution failed:
roads.cpp:17:16: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   17 |     tie(u,w) = y;
      |                ^
roads.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   while(ed < bor && now != S.size()){
      |                     ~~~~^~~~~~~~~~~
roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int i=0;i<W.size();i++){
      |               ~^~~~~~~~~
roads.cpp:43:10: error: could not convert 'A' from 'vector<int>' to 'vector<long long int>'
   43 |   return A;
      |          ^
      |          |
      |          vector<int>