제출 #758587

#제출 시각아이디문제언어결과실행 시간메모리
758587KN200711경주 (Race) (IOI11_race)C++14
100 / 100
433 ms111124 KiB
#include "race.h" # include <bits/stdc++.h> # define ll long long # define fi first # define se second using namespace std; set< pair<ll, int> > nw[200001]; vector< pair<ll, int> > edge[200001]; int ans = 1e9 + 11; int KK; void dfs(int a, int pr, ll v, int c) { nw[a].insert(make_pair(v, c)); for(int k=0;k<edge[a].size();k++) { if(edge[a][k].fi == pr) continue; dfs(edge[a][k].fi, a, v + edge[a][k].se, c+1); if(nw[edge[a][k].fi].size() > nw[a].size()) swap(nw[a], nw[edge[a][k].fi]); for(auto p : nw[edge[a][k].fi]) { auto it = nw[a].lower_bound(make_pair(KK + 2ll * v - p.fi, 0)); if(it == nw[a].end()) continue; if(it->fi == KK + 2ll * v - p.fi) ans = min(ans, it->se + p.se - 2 * c); } for(auto p : nw[edge[a][k].fi]) { nw[a].insert(p); } } } int best_path(int N, int K, int H[][2], int L[]) { KK = K; for(int i=0;i<N;i++) { edge[i].clear(); nw[i].clear(); } for(int i=0;i<N-1;i++) { edge[H[i][0]].push_back(make_pair(H[i][1], L[i])); edge[H[i][1]].push_back(make_pair(H[i][0], L[i])); } ans = 1e9 + 11; dfs(0, -1, 0, 0); if(ans == 1e9 + 11) return -1; return ans; }

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

race.cpp: In function 'void dfs(int, int, long long int, int)':
race.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int k=0;k<edge[a].size();k++) {
      |              ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...