Submission #988877

#TimeUsernameProblemLanguageResultExecution timeMemory
988877NoLoveRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
/** * author : Lăng Trọng Đạt * created: 26-05-2024 **/ #include <bits/stdc++.h> using namespace std; #ifndef LANG_DAT #define db(...) ; #endif // LANG_DAT #define int long long #define mp make_pair #define f first #define se second #define pb push_back #define all(v) (v).begin(), (v).end() using pii = pair<int, int>; using vi = vector<int>; #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++) void mx(int& a, int b) { if (b > a) a = b; } void mi(int& a, int b) { if (b < a) a = b; } #define si(x) (int)(x.size()) const int INF = 1e18; const int MOD = 1e9 + 7; const int MAXN = 5e5 + 5; int g[MAXN]; int n, ans = INF, k; vector<pii> adj[MAXN]; map<int, int> md[MAXN]; // md[v][l] = độ sâu lớn nhất khi đi khoảng cách từ node đó đến root đúng = l void dfs(int v, int prv, int len, int d) { md[v][len] = d; for (auto[u, l] : adj[v]) { if (u == prv) continue; dfs(u, v, len + l, d + 1); if (si(md[u]) > si(md[v])) swap(md[u], md[v]); // x + y - 2 * len = k // length = depth + depth_y - 2*d for (auto[x, depth] : md[u]) { if (md[v].count(k + 2*len - x)) { mi(ans, depth + md[v][k + 2*len - x] - 2*d); } } for (auto[x, depth] : md[u]) { if (md[v].count(x)) { mi(md[v][x], depth); } else { md[v][x] = depth; } } } db(v, md[v]) } int best_path(int N, int K, int H[][2], int L[]) { k = K; FOR(i, 0, N - 2) { adj[H[i][0]].pb({H[i][1], L[i]}); adj[H[i][1]].pb({H[i][0], L[i]}); } dfs(1, -1, 0, 0); db(ans); return (ans == INF ? -1 : ans); }

Compilation message (stderr)

race.cpp: In function 'void dfs(long long int, long long int, long long int, long long int)':
race.cpp:33:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |     for (auto[u, l] : adj[v]) {
      |              ^
race.cpp:39:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |         for (auto[x, depth] : md[u]) {
      |                  ^
race.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |         for (auto[x, depth] : md[u]) {
      |                  ^
race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
race.cpp:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 0, N - 2) {
      |     ^~~
/usr/bin/ld: /tmp/ccwq369u.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