제출 #1090507

#제출 시각아이디문제언어결과실행 시간메모리
1090507vivkostov경주 (Race) (IOI11_race)C++14
0 / 100
3 ms4956 KiB
#include <bits/stdc++.h> using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } struct cell { int a,b,c; void read() { cin>>a>>b>>c; } }; int n,k,used[200005],dp[200005]; cell a[200005]; vector<cell>v[200005]; map<int,int>m,ne; int otg; void make_dp(int beg) { int w; used[beg]=1; dp[beg]=1; for(int i=0;i<v[beg].size();i++) { w=v[beg][i].b; if(!used[w]) { make_dp(w); dp[beg]+=dp[w]; } } } void cl(int beg,int par) { int w; used[beg]=0; for(int i=0;i<v[beg].size();i++) { w=v[beg][i].b; if(w!=par&&used[w]!=2)cl(w,beg); } } void dfs(int beg,int st,int lead,int br) { used[beg]=1; cell w; if(!ne[st]) { //cout<<beg<<endl; ne[st]=br; } else ne[st]=min(ne[st],br); for(int i=0;i<v[beg].size();i++) { w=v[beg][i]; if(!used[w.b]) { dfs(w.b,st+w.c,lead,br+1); } if(beg==lead) { for(auto j=ne.begin();j!=ne.end();j++) { int h=j->first; if(m[k-h])otg=min(otg,m[k-h]+j->second); if(m[h])m[h]=min(m[h],ne[h]); else m[h]=ne[h]; } ne.clear(); } } } void find_centroid(int beg,int par,int br) { int w,l=0; used[beg]=1; for(int i=0;i<v[beg].size();i++) { w=v[beg][i].b; if(!used[w]&&dp[w]>=(br+1)/2) { find_centroid(w,beg,br); l=1; } } if(!l) { cl(beg,beg); m[0]=0; dfs(beg,0,beg,0); m.clear(); cl(beg,beg); used[beg]=2; for(int i=0;i<v[beg].size();i++) { w=v[beg][i].b; if(!used[w]) { make_dp(w); cl(w,w); find_centroid(w,w,dp[w]); } } } } int best_path(int N,int K,int H[][2],int L[]) //void read() { //cin>>n>>k; n=N; k=K; for(int i=1;i<n;i++) { //cin>>a[i].a>>a[i].b; a[i].a=H[i][0]; a[i].b=H[i][1]; } for(int i=1;i<n;i++) { //cin>>a[i].c; a[i].c=L[i]; v[a[i].a].push_back(a[i]); swap(a[i].a,a[i].b); v[a[i].a].push_back(a[i]); } otg=1000000000; dfs(0,0,0,0); make_dp(0); cl(0,0); find_centroid(0,0,dp[0]); return otg; } /*int main() { speed(); read(); return 0; } */

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

race.cpp: In function 'void make_dp(int)':
race.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
race.cpp: In function 'void cl(int, int)':
race.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
race.cpp: In function 'void dfs(int, int, int, int)':
race.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
race.cpp: In function 'void find_centroid(int, int, int)':
race.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
race.cpp:98:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |         for(int i=0;i<v[beg].size();i++)
      |                     ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...