제출 #94491

#제출 시각아이디문제언어결과실행 시간메모리
94491adlet경주 (Race) (IOI11_race)C++17
0 / 100
10 ms5112 KiB
#include <bits/stdc++.h> #include "race.h" using namespace std; const int INF = 1e9; const int NN = 2e5 + 5; int ans = INF, k; vector < pair < int, int > > g[NN]; inline void dfs(int v, int sum = 0, int p = -1, int h = 0) { // if (sum > k || h > ans) // return; if (sum == k) { ans = min(ans, h); // return; } for (auto node : g[v]) { int to = node.first, len = node.second; if (to == p) continue; dfs(to, sum + len, v, h + 1); } } int best_path(int N, int K, int H[][2], int L[]){ k = K; int ok = 0; for (int i = 0; i < N; ++i) { int v = H[i][0] + 1, u = H[i][1] + 1; g[v].push_back({u, L[i]}); g[u].push_back({v, L[i]}); } for (int i = 1; i <= N; ++i) dfs(i); if (ans == INF) ans = -1; return ans; } /* */

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

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:30:9: warning: unused variable 'ok' [-Wunused-variable]
     int ok = 0;
         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...