제출 #558667

#제출 시각아이디문제언어결과실행 시간메모리
558667hoanghq2004Fireworks (APIO16_fireworks)C++14
0 / 100
7 ms340 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 3e2 + 10; int n, m; vector <pair <int, int> > g[N]; int f[N][N]; int cur[N]; void dfs(int u, int p) { if (g[u].empty()) { memset(f[u], 60, sizeof(f[u])); f[u][0] = 0; } for (auto [v, w]: g[u]) { if (v == p) continue; dfs(v, u); memset(cur, 60, sizeof(cur)); for (int i = 0; i <= 300; ++i) { for (int j = 0; j <= 300; ++j) cur[i] = min(cur[i], f[v][j] + abs(i - (w + j))); } for (int i = 0; i <= 300; ++i) f[u][i] += cur[i]; } } int main() { ios :: sync_with_stdio(0); cin.tie(0); cin >> n >> m; n += m; for (int v = 2; v <= n; ++v) { int u, w; cin >> u >> w; g[u].push_back({v, w}); } dfs(1, 0); cout << *min_element(f[1], f[1] + 300 + 1); }

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

fireworks.cpp: In function 'void dfs(int, int)':
fireworks.cpp:25:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |     for (auto [v, w]: g[u]) {
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...