Submission #923856

#TimeUsernameProblemLanguageResultExecution timeMemory
923856WhisperRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using T = tuple<ll, ll, ll>; #define int long long #define Base 41 #define sz(a) (int)a.size() #define FOR(i, a, b) for ( int i = a ; i <= b ; i++ ) #define FORD(i, a, b) for (int i = b; i >= a; i --) #define REP(i, n) for (int i = 0; i < n; ++i) #define REPD(i, n) for (int i = n - 1; i >= 0; --i) #define all(x) x.begin() , x.end() #define pii pair<int , int> #define fi first #define se second #define Lg(x) 31 - __builtin_clz(x) #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) constexpr ll LINF = (1ll << 60); constexpr int INF = (1ll << 30); constexpr int MAX = 2e5 + 5; constexpr int Mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class X, class Y> bool minimize(X &x, const Y &y){ X eps = 1e-9; if (x > y + eps) {x = y; return 1;} return 0; } template <class X, class Y> bool maximize(X &x, const Y &y){ X eps = 1e-9; if (x + eps < y) {x = y; return 1;} return 0; } int numNode, k; vector<pii> adj[MAX]; int sz[MAX], del[MAX]; void reSubsize(int u, int p){ sz[u] = 1; for (auto&[v, w] : adj[u]) if(v ^ p){ if (del[v]) continue; reSubsize(v, u); sz[u] += sz[v]; } } int getCentroid(int u, int p, int siz){ for (auto&[v, w] : adj[u]) if(v ^ p){ if (!del[v] && sz[v] * 2 > siz) return getCentroid(v, u, siz); } return u; } int f[5 * MAX]; int ans = LINF; vector<int> save; void dfs(int u, int p, int l, int dep, bool ok){ if (l > k) return; if (ok) minimize(ans, f[k - l] + dep); else{ minimize(f[l], dep); save.push_back(l); } for (auto&[v, w] : adj[u]) if(v ^ p){ if (!del[v]) dfs(v, u, l + w, dep + 1, ok); } } void decompose(int root){ reSubsize(root, -1); int siz = sz[root]; root = getCentroid(root, -1, siz); del[root] = 1; for (auto&[v, w] : adj[root]){ if (del[v]) continue; dfs(v, root, w, 1, 1); dfs(v, root, w, 1, 0); } for (auto&v : save) f[v] = 1e18; save.clear(); for (auto&[v, w] : adj[root]) if (!del[v]){ decompose(v); } } int best_path(int n, int k, int h[][2], int l[]) { numNode = N, k = K; for (int i = 1; i < numNode; ++i){ int u = H[i][0], v = H[i][1], w = L[i]; ++u, ++v; adj[u].push_back({v, w}); adj[v].push_back({u, w}); } memset(f, 0x3f, sizeof f); decompose(1); return (ans > 1e15 ? -1 : ans); }

Compilation message (stderr)

race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:94:15: error: 'N' was not declared in this scope
   94 |     numNode = N, k = K;
      |               ^
race.cpp:94:22: error: 'K' was not declared in this scope
   94 |     numNode = N, k = K;
      |                      ^
race.cpp:96:17: error: 'H' was not declared in this scope
   96 |         int u = H[i][0], v = H[i][1], w = L[i];
      |                 ^
race.cpp:97:16: error: 'v' was not declared in this scope
   97 |         ++u, ++v;
      |                ^
race.cpp:98:30: error: 'w' was not declared in this scope
   98 |         adj[u].push_back({v, w});
      |                              ^
race.cpp:98:32: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   98 |         adj[u].push_back({v, w});
      |                                ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~