제출 #974638

#제출 시각아이디문제언어결과실행 시간메모리
974638Amaarsaa경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
/* * Written by * ______ _ _ ______ ____ ____ ____ ____ * |_ _|| |_| ||_ _||_ || __ || __ |/ _/ * | | | _ | | | / / || |||| ||| |__ * | | | | | | | | | |_ ||__||||__||\__ \ * |__| |_| |_| |__| |___||____||____|/____/ */ #include <bits/stdc++.h> using namespace std; #define nmax 200020 #define ii pair<int, int> #define ll long long int n, k, ans, cnt[1000100], sz[nmax], r[nmax]; vector<ii> adj[nmax]; inline void minimize(int &a, int b) { if(a == -1 || a > b) a = b; } int dfs(int u, int p = -1) { sz[u] = 1; for(auto [C, v]: adj[u]) { if(v != p && !r[v]) sz[u] += dfs(v, u); } return sz[u]; } int get_centroid(int m, int u, int p = -1) { for(auto [C, v]: adj[u]) { if(v != p && !r[v] && 2 * sz[v] > m) return get_centroid(m, v, u); } return u; } void get_cnt(int sum, bool filling, int u, int p = -1, int depth = 1) { if(sum > k) return; if(filling) minimize(cnt[sum], depth); else { if(cnt[k - sum] != -1) minimize(ans, depth + cnt[k - sum]); } for(auto [C, v]: adj[u]) { if(v != p && !r[v]) get_cnt(sum + C, filling, v, u, depth + 1); } } void del(int sum, int u, int p = -1) { if(sum > k) return; cnt[sum] = -1; for(auto [C, v]: adj[u]) { if(v != p && !r[v]) del(sum + C, v, u); } } void centroid(int u = 0) { u = get_centroid(dfs(u), u); r[u] = 1; cnt[0] = 0; for(auto [C, v]: adj[u]) { if(!r[v]) { get_cnt(C, false, v); get_cnt(C, true, v); } } for(auto [C, v]: adj[u]) { if(!r[v]) { del(C, v); } } for(auto [C, v]: adj[u]) { if(!r[v]) centroid(v); } } int best_path(int N, int K, int h[][2], int L[]) { n = N; k = K; for(int i = 0, u, v; i < n - 1; ++i) { u = h[i][0]; v = h[i][1]; adj[u].push_back(ii(l[i], v)); adj[v].push_back(ii(l[i], u)); } ans = -1; memset(cnt, -1, sizeof(cnt)); centroid(); return ans; }

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

race.cpp: In function 'int dfs(int, int)':
race.cpp:29:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp: In function 'int get_centroid(int, int, int)':
race.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp: In function 'void get_cnt(int, bool, int, int, int)':
race.cpp:52:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp: In function 'void del(int, int, int)':
race.cpp:61:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp: In function 'void centroid(int)':
race.cpp:72:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   72 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp:78:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   78 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp:83:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   83 |     for(auto [C, v]: adj[u]) {
      |              ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:95:29: error: 'l' was not declared in this scope
   95 |         adj[u].push_back(ii(l[i], v));
      |                             ^