제출 #1047804

#제출 시각아이디문제언어결과실행 시간메모리
1047804Marco_Escandon도로 폐쇄 (APIO21_roads)C++17
0 / 100
2091 ms23424 KiB
//#include "roads.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define x first #define y second ll n; vector<vector<pair<ll,ll>>> cad; ll k; ll sol(ll node,ll B, ll P) { if(B>k) return 1e14; vector<pair<ll,ll>> asd; for(auto i:cad[node]) { if(i.x==P) continue; asd.push_back({sol(i.x,1,node),i.y+sol(i.x,0,node)}); } if(asd.size()==0) return 0; vector<ll> dp(asd.size()+1,1e14); vector<ll> dp2=dp; dp[0]=0; for(int i=0; i<asd.size(); i++) { for(int j=dp.size()-1; j>-1; j--) { dp2[j]=dp[j]+asd[i].y,dp[j]; if(j>0) dp2[j]=min(dp[j-1]+asd[i].x,dp2[j]); } swap(dp,dp2); } if(k-B>=dp.size()) return dp.back(); return dp[k-B]; } std::vector<long long> minimum_closure_costs(int N, std::vector<int> U,std::vector<int> V,std::vector<int> W) { n=N; cad.resize(n+1); for(int i=0; i<n-1; i++) { cad[U[i]].push_back({V[i],W[i]}); cad[V[i]].push_back({U[i],W[i]}); } vector<ll> s(n,0); for(int i=0; i<n; i++) { k=i; s[i]=sol(0,0,-1); } return s; }

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

roads.cpp: In function 'll sol(ll, ll, ll)':
roads.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0; i<asd.size(); i++)
      |                  ~^~~~~~~~~~~
roads.cpp:32:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     if(k-B>=dp.size()) return dp.back();
      |        ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...