제출 #1091286

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

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

race.cpp: In function 'void make_dp(long long int)':
race.cpp:28:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(long long int i=0;i<v[beg].size();i++)
      |                           ~^~~~~~~~~~~~~~
race.cpp: In function 'void cl(long long int, long long int)':
race.cpp:42:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(long long int i=0;i<v[beg].size();i++)
      |                           ~^~~~~~~~~~~~~~
race.cpp: In function 'void dfs(long long int, long long int, long long int, long long int)':
race.cpp:58:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(long long int i=0;i<v[beg].size();i++)
      |                           ~^~~~~~~~~~~~~~
race.cpp: In function 'void find_centroid(long long int, long long int, long long int)':
race.cpp:90:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |     for(long long int i=0;i<v[beg].size();i++)
      |                           ~^~~~~~~~~~~~~~
race.cpp:106:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |         for(long long int i=0;i<v[beg].size();i++)
      |                               ~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccNVQoTD.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status