Submission #648298

#TimeUsernameProblemLanguageResultExecution timeMemory
648298smirichtoRace (IOI11_race)C++17
Compilation error
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; }

Compilation message (stderr)

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));
      |                             ^