제출 #1095005

#제출 시각아이디문제언어결과실행 시간메모리
1095005blackslexMuseum (CEOI17_museum)C++17
100 / 100
865 ms786256 KiB
#include<bits/stdc++.h> using namespace std; using pii = pair<int, int>; int n, k, c, x, y, z; int main() { scanf("%d %d %d", &n, &k, &c); vector<int> sz(n + 5, 1); vector<vector<pii>> v(n + 5, vector<pii>()); vector<vector<vector<int>>> dp(n + 5, vector<vector<int>>(2, vector<int>(n + 5, 1e9))); for (int i = 1; i < n; i++) { scanf("%d %d %d", &x, &y, &z); v[x].emplace_back(y, z); v[y].emplace_back(x, z); } function<void(int, int)> dfs = [&] (int cur, int par) { for (auto i: {0, 1}) { for (auto j: {0, 1}) dp[cur][i][j] = 0; } for (auto &[x, y]: v[cur]) { if (par == x) continue; dfs(x, cur); for (int i = sz[cur]; ~i; i--) { for (int j = sz[x]; ~j; j--) { dp[cur][0][i + j] = min(dp[cur][0][i + j], dp[cur][1][i] + dp[x][0][j] + y); dp[cur][0][i + j] = min(dp[cur][0][i + j], dp[cur][0][i] + dp[x][1][j] + y * 2); dp[cur][1][i + j] = min(dp[cur][1][i + j], dp[cur][1][i] + dp[x][1][j] + y * 2); } } sz[cur] += sz[x]; } }; dfs(c, 0); printf("%d", min(dp[c][0][k], dp[c][1][k])); }

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

museum.cpp: In function 'int main()':
museum.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d %d", &n, &k, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
museum.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d %d %d", &x, &y, &z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...