제출 #418601

#제출 시각아이디문제언어결과실행 시간메모리
418601snasibov05경주 (Race) (IOI11_race)C++14
9 / 100
3075 ms123248 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 vector<vector<pii>> ed; vector<vector<vector<int>>> dp; void dfs(int cur, int pr, int k){ dp[0][0][cur] = dp[1][0][cur] = 0; for (auto [to, dist] : ed[cur]){ if (to == pr) continue; dfs(to, cur, k); vector<int> v(k+1, oo); for (int i = 1; i <= k; ++i) { for (int j = 0; j <= i - dist; ++j) { v[i] = min(v[i], dp[1][i-dist-j][to] + dp[1][j][cur] + 1); } } for (int i = 1; i <= k; ++i) { //if (i - dist >= 0) dp[1][i][cur] = min(dp[1][i][cur], dp[1][i - dist][to] + 1); dp[1][i][cur] = min(dp[1][i][cur], v[i]); dp[0][i][cur] = min(min(dp[0][i][cur], dp[1][i][cur]), min(dp[0][i][to], dp[1][i][to])); } } } int best_path(int n, int k, int h[][2], int l[]){ ed.resize(n); dp.resize(2); dp.assign(2, vector<vector<int>>(k+1, vector<int>(n, 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 (dp[0][k][0] == oo) dp[0][k][0] = -1; return dp[0][k][0]; }

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

race.cpp: In function 'void dfs(int, int, int)':
race.cpp:17:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |     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...