제출 #1014054

#제출 시각아이디문제언어결과실행 시간메모리
1014054Tienthanh2007경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; const int maxn = 2e5 + 5; int n, k; vector <pii> adj[maxn]; int child[maxn]; bool del[maxn]; int cnt[1000005], mx_depth = 0; int res = 1e9; void count_child(int u, int par){ child[u] = 1; for(auto [w, v] : adj[u]){ if(v == par || del[v]) continue; count_child(v, u); child[u] += child[v]; } } int find_centroid(int u, int par, int sz){ for(auto [w, v] : adj[u]){ if(v == par || del[v]) continue; if(child[v] >= sz / 2) return find_centroid(v, u, sz); } return u; } void get_cnt(int u, int par, bool filling, int Rank, int depth){ if(depth > k) return; mx_depth = max(mx_depth, depth); if(filling) cnt[depth] = min(cnt[depth], Rank); else res = min(res, cnt[k - depth] + Rank); for(auto [w, v] : adj[u]){ if(v == par || del[v]) continue; get_cnt(v, u, filling, Rank + 1, depth + w); } } void decomposition(int u){ count_child(u, -1); int sz = child[u]; int centroid = find_centroid(u, -1, sz); del[centroid] = 1; mx_depth = 0; for(auto [w, v] : adj[centroid]){ if(del[v]) continue; get_cnt(v, centroid, false, 1, w); get_cnt(v, centroid, true, 1, w); } fill(cnt, cnt + mx_depth, 1e9); for(auto [w, v] : adj[centroid]){ if(del[v]) continue; decomposition(v); } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 1; i <= n - 1; i ++){ int u, v, w; cin >> u >> v >> w; adj[u].push_back({w, v}); adj[v].push_back({w, u}); } fill(cnt, cnt + 1000000, 1e9); decomposition(0); if(res == 1e9) res = -1; cout << res; return 0; }

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

race.cpp: In function 'void count_child(int, int)':
race.cpp:17:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |     for(auto [w, v] : adj[u]){
      |              ^
race.cpp: In function 'int find_centroid(int, int, int)':
race.cpp:25:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |     for(auto [w, v] : adj[u]){
      |              ^
race.cpp: In function 'void get_cnt(int, int, bool, int, int)':
race.cpp:38:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |     for(auto [w, v] : adj[u]){
      |              ^
race.cpp: In function 'void decomposition(int)':
race.cpp:50:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |     for(auto [w, v] : adj[centroid]){
      |              ^
race.cpp:56:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   56 |     for(auto [w, v] : adj[centroid]){
      |              ^
/usr/bin/ld: /tmp/ccvvP92T.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgGG6eU.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccgGG6eU.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status