제출 #969848

#제출 시각아이디문제언어결과실행 시간메모리
969848europium도로 폐쇄 (APIO21_roads)C++17
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <vector> #include <bits/stdc++.h> using namespace std; void dfs(int node, int parent, int k, vector<vector<pair<int, int>>>& graph, vector<vector<int>>& dp) { dp[node][0] = 0; dp[node][1] = 0; for (auto& edge : graph[node]) { int child = edge.first; int cost = edge.second; if (child == parent) { continue; } dfs(child, node, k, graph, dp); for (int i = k; i >= 0; --i) { dp[node][i] += min(dp[child][min(i, k)] , dp[child][0]); } } } vector<ll> minimum_closure_costs(int N, vector<int>& U, vector<int>& V, vector<int>& W) { vector<vector<pair<int, int>>> graph(N); for (int i = 0; i < N - 1; ++i) { graph[U[i]].push_back({V[i], W[i]}); graph[V[i]].push_back({U[i], W[i]}); } vector<vector<int>> dp(N, vector<int>(N + 1, numeric_limits<int>::max())); vector<int> result; for (int k = 0; k < N; ++k) { dfs(0, -1, k, graph, dp); result.push_back(dp[0][k]); } return result; }

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

roads.cpp: In function 'void dfs(int, int, int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<std::vector<int> >&)':
roads.cpp:13:13: warning: unused variable 'cost' [-Wunused-variable]
   13 |         int cost = edge.second;
      |             ^~~~
roads.cpp: At global scope:
roads.cpp:24:8: error: 'll' was not declared in this scope
   24 | vector<ll> minimum_closure_costs(int N, vector<int>& U, vector<int>& V, vector<int>& W) {
      |        ^~
roads.cpp:24:10: error: template argument 1 is invalid
   24 | vector<ll> minimum_closure_costs(int N, vector<int>& U, vector<int>& V, vector<int>& W) {
      |          ^
roads.cpp:24:10: error: template argument 2 is invalid
roads.cpp: In function 'int minimum_closure_costs(int, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
roads.cpp:39:12: error: cannot convert 'std::vector<int>' to 'int' in return
   39 |     return result;
      |            ^~~~~~