제출 #418617

#제출 시각아이디문제언어결과실행 시간메모리
418617snasibov05경주 (Race) (IOI11_race)C++14
31 / 100
432 ms262148 KiB
#include "race.h" #include <vector> using namespace std; #define oo 1000000000 #define pii pair<int, int> #define pb push_back #define f first #define s second int ans = oo; vector<vector<pii>> ed; vector<vector<int>> dp; void dfs(int cur, int pr, int k){ dp[cur][0] = 0; for (auto [to, dist] : ed[cur]){ if (to == pr) continue; dfs(to, cur, k); for (int i = 0; i <= k; ++i) { if (i - dist >= 0 && i <= k) ans = min(ans, dp[to][i - dist] + dp[cur][k - i] + 1); } for (int i = 0; i <= k; ++i) { if (i - dist >= 0) dp[cur][i] = min(dp[cur][i], dp[to][i-dist] + 1); } } } int best_path(int n, int k, int h[][2], int l[]){ ed.resize(n); dp.resize(n); dp.assign(n, vector<int>(k+1, oo)); for (int i = 0; i < n - 1; ++i) { ed[h[i][0]].pb({h[i][1], l[i]}); ed[h[i][1]].pb({h[i][0], l[i]}); } dfs(0, -1, k); if (ans == oo) ans = -1; return ans; }

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

race.cpp: In function 'void dfs(int, int, int)':
race.cpp:18:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |     for (auto [to, dist] : ed[cur]){
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...