제출 #592651

#제출 시각아이디문제언어결과실행 시간메모리
592651ikaurov경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define all(arr) (arr).begin(), (arr).end() #define ll long long #define ld long double #define pb push_back #define sz(x) int((x).size()) #define fi first #define se second #define endl '\n' const int N = 2e5 + 20, INF = 1e9; vector<pair<int, int>> g[N]; map<ll, int> min_edges[N]; ll delta_length[N], delta_cnt[N]; ll ans = INF, K; void dfs(int v, int p){ int maxguy = -1, maxw; for (auto [u, w] : g[v]){ if (u == p) continue; dfs(u, v); if (maxguy == -1 || sz(min_edges[maxguy]) < sz(min_edges[u])) maxguy = u, maxw = w; } if (maxguy != -1){ min_edges[v] = move(min_edges[maxguy]), delta_length[v] = delta_length[maxguy] + maxw, delta_cnt[v] = delta_cnt[maxguy] + 1; } for (auto [u, w] : g[v]){ if (u == p) continue; if (u != maxguy){ for (auto [len, cnt] : min_edges[u]){ ll len1 = len + delta_length[u] + w - delta_length[v]; int cnt1 = cnt + delta_cnt[u] + 1 - delta_cnt[v]; if (min_edges[v].count(K - len1 - 2 * delta_length[v])){ ans = min(ans, cnt1 + 2 * delta_cnt[v] + min_edges[v][K - len1 - 2 * delta_length[v]]); } if (min_edges[v].count(len1)) min_edges[v][len1] = min(min_edges[v][len1], cnt1); else min_edges[v][len1] = cnt1; } min_edges[u].clear(); } } min_edges[v][-delta_length[v]] = -delta_cnt[v]; if (min_edges[v].count(K - delta_length[v])) ans = min(ans, min_edges[v][K - delta_length[v]] + delta_cnt[v]); } int best_path(int n, int k, int h[][2], int l[]){ for (int i = 0; i < n; i++){ g[i].clear(); min_edges[i].clear(); delta_length[i] = delta_cnt[i] = 0; } K = k, ans = INF; for (int i = 0; i < n - 1; i++){ g[h[i][0]].pb({h[i][1], l[i]}); g[h[i][1]].pb({h[i][0], l[i]}); } dfs(0, 0); return ans == INF? -1 : ans; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); // cout.precision(20); // int n, k; // cin >> n >> k; // int h[n - 1][2], l[n - 1]; // for (int i = 0; i < n - 1; i++){ // cin >> h[i][0] >> h[i][1]; // } // for (int i = 0; i < n - 1; i++){ // cin >> l[i]; // } // cout << best_path(n, k, h, l) << endl; }

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

race.cpp: In function 'void dfs(int, int)':
race.cpp:22:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |   for (auto [u, w] : g[v]){
      |             ^
race.cpp:31:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |   for (auto [u, w] : g[v]){
      |             ^
race.cpp:34:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |       for (auto [len, cnt] : min_edges[u]){
      |                 ^
/usr/bin/ld: /tmp/ccmG88QS.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUTChEP.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status