Submission #1053245

#TimeUsernameProblemLanguageResultExecution timeMemory
1053245vincentbucourt1Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second const static int INF = 1e9; const int MAXN = 200001; static int N, sumNeed; static vector<pair<int, int>> adj[MAXN]; static int depth[MAXN], sum[MAXN]; static map<int, int> maps[MAXN]; static int ans = INF; void dfs (int node = 0, int parent = -1) { maps[node][sum[node]] = depth[node]; for (pair<int, int> nxt : adj[node]) { int nodenxt = nxt.f, weightnxt = nxt.s; if (nodenxt == parent) continue; depth[nodenxt] = depth[node] + 1; sum[nodenxt] = sum[node] + weightnxt; dfs(nodenxt, node); if (maps[nodenxt].size() > maps[node].size()) swap(maps[nodenxt], maps[node]); for (pair<ll, ll> elem : maps[nodenxt]) { int sumOn = elem.f, depthOn = elem.s; int need = -sumOn + 2*sum[node] + sumNeed; if (maps[node].find(need) != maps[node].end()) { ans = min(ans, maps[node][need] - 2*depth[node] + depthOn); } if (maps[node].find(sumOn) == maps[node].end()) { maps[node][sumOn] = depthOn; } else { maps[node][sumOn] = min(maps[node][sumOn], depthOn); } } maps[nodenxt].clear(); } } int best_path(int N, int K, int H[][2], int L[]) { ::N = N; sumNeed = K; for (int i = 0; i < N-1; i++) { adj[H[i][0]].push_back({H[i][1], L[i]}); adj[H[i][1]].push_back({H[i][0], L[i]}); } dfs(); if (ans == INF) return -1; else return ans; }

Compilation message (stderr)

race.cpp: In function 'void dfs(long long int, long long int)':
race.cpp:30:13: error: 'll' was not declared in this scope
   30 |   for (pair<ll, ll> elem : maps[nodenxt]) {
      |             ^~
race.cpp:30:19: error: template argument 1 is invalid
   30 |   for (pair<ll, ll> elem : maps[nodenxt]) {
      |                   ^
race.cpp:30:40: error: cannot convert 'std::pair<const long long int, long long int>' to 'int' in initialization
   30 |   for (pair<ll, ll> elem : maps[nodenxt]) {
      |                                        ^
race.cpp:5:11: error: request for member 'first' in 'elem', which is of non-class type 'int'
    5 | #define f first
      |           ^~~~~
race.cpp:31:21: note: in expansion of macro 'f'
   31 |    int sumOn = elem.f, depthOn = elem.s;
      |                     ^
race.cpp:35:55: error: 'depthOn' was not declared in this scope; did you mean 'depth'?
   35 |     ans = min(ans, maps[node][need] - 2*depth[node] + depthOn);
      |                                                       ^~~~~~~
      |                                                       depth
race.cpp:39:25: error: 'depthOn' was not declared in this scope; did you mean 'depth'?
   39 |     maps[node][sumOn] = depthOn;
      |                         ^~~~~~~
      |                         depth
race.cpp:42:48: error: 'depthOn' was not declared in this scope; did you mean 'depth'?
   42 |     maps[node][sumOn] = min(maps[node][sumOn], depthOn);
      |                                                ^~~~~~~
      |                                                depth