제출 #221292

#제출 시각아이디문제언어결과실행 시간메모리
221292a_player경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; const int nax=2e5+5; typedef long long ll; struct node{ int a,c; ll b; }; vector<node> grafo[nax]; int ans=INT_MAX; int N,K; int ss,cc; map<ll,int> m; void incl(int n, int a, int d, ll v){ if(K<v)return; if(a!=-1){ if(m.count(K-v))ans=min(ans,m[K-v]+d); if(!m.count(v))m[v]=d; else m[v]=min(m[v],d); }else{ m.clear(); } for(auto x:grafo[n]){ if(!x.c||x.a==a)continue; incl(x.a,n,d+1,v+x.b); } } int findc(int n, int a, int& c, int num){ int s=0; for(auto x:grafo[n]){ if(!x.c||x.a==a)continue; s+=findc(x.a,n,c,num); } if(abs(s-num/2)<=1)c=n; return s+1; } int findsize(int n, int a){ int s=0; for(auto x:grafo[n]){ if(!x.c||x.a==a)continue; s+=findsize(x.a,n); } return s+1; } void centroid(int n){ incl(n,-1,0,0); for(int i=0;i<grafo[n].size();i++)grafo[n][i].c=0; for(auto x:grafo[n]){ ss=findsize(x.a,-1); findc(x.a,-1,cc,ss); centroid(cc); } } int best_path(int N, int K, int H[][2], int L[]){ ::N=N,::K=K; for(int i=0;i<N-1;i++){ grafo[H[i][0]].push_back({H[i][1],1,(ll)L[i]}); grafo[H[i][1]].push_back({H[i][0],1,(ll)L[i]}); } ss=findsize(0,-1); findc(0,-1,cc,ss); centroid(c); return ans; }

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

race.cpp: In function 'void centroid(int)':
race.cpp:52:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<grafo[n].size();i++)grafo[n][i].c=0;
               ~^~~~~~~~~~~~~~~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:69:12: error: 'c' was not declared in this scope
   centroid(c);
            ^