제출 #488785

#제출 시각아이디문제언어결과실행 시간메모리
488785Theo830도로 폐쇄 (APIO21_roads)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///APIO 2021 vc #include "roads.h" vector<vector<ii> >adj; ll dp[2005][2]; ll solve(ll idx,ll k,ll p,bool ep){ if(dp[idx][ep] != -1){ return dp[idx][ep]; } ll ans = INF; ll siz = k - ep; vll ex; ll sum = 0; for(auto x:adj[idx]){ if(x.F != p){ sum += x.S + solve(x.F,k,idx,0); ex.pb(solve(x.F,k,idx,1) - (x.S + solve(x.F,k,idx,0))); } } ans = sum; sort(all(ex)); f(i,0,min((1LL) * ex.size(),siz)){ ans += ex[i]; } return dp[idx][ep] = ans; } std::vector<long long> minimum_closure_costs(int N, std::vector<int> U,std::vector<int> V,std::vector<int> W){ vll ans; adj.assign(N+5,vector<ii>()); f(i,0,N-1){ adj[U[i]].pb(ii(V[i],W[i])); adj[V[i]].pb(ii(U[i],W[i])); } f(k,0,N){ memset(dp,-1,sizeof dp); ans.pb(solve(1,k,0,0)); } return ans; }

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

roads.cpp: In function 'll solve(ll, ll, ll, bool)':
roads.cpp:44:36: error: no matching function for call to 'min(long long unsigned int, ll&)'
   44 |     f(i,0,min((1LL) * ex.size(),siz)){
      |                                    ^
roads.cpp:8:35: note: in definition of macro 'f'
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
      |                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from roads.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
roads.cpp:44:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'll' {aka 'long long int'})
   44 |     f(i,0,min((1LL) * ex.size(),siz)){
      |                                    ^
roads.cpp:8:35: note: in definition of macro 'f'
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
      |                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from roads.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
roads.cpp:44:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'll' {aka 'long long int'})
   44 |     f(i,0,min((1LL) * ex.size(),siz)){
      |                                    ^
roads.cpp:8:35: note: in definition of macro 'f'
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
roads.cpp:44:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   44 |     f(i,0,min((1LL) * ex.size(),siz)){
      |                                    ^
roads.cpp:8:35: note: in definition of macro 'f'
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
roads.cpp:44:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   44 |     f(i,0,min((1LL) * ex.size(),siz)){
      |                                    ^
roads.cpp:8:35: note: in definition of macro 'f'
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
      |                                   ^