Submission #1067042

#TimeUsernameProblemLanguageResultExecution timeMemory
1067042ThunnusRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include "race.h" #include<bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define fi first #define se second #define sz(x) (int)(x).size() const int MAXN = 2e5 + 5; int ans = LLONG_MAX, k; vector<map<int, int>> mp(MAXN); inline void dfs(vector<vector<pii>> &adj, int v = 0, int p = -1, int dist = 0, int dep = 0){ for(pii &u : adj[v]){ if(u.fi == p) continue; dfs(adj, u, v, dist + u.se, dep + 1); } mp[v][dist] = dep; for(pii &u : adj[v]){ if(u.fi == p) continue; if(sz(mp[u.fi]) > sz(mp[v])) mp[v].swap(mp[u.fi]); for(auto &it : mp[u.fi]){ if(mp[v].count(k - (it.fi - 2 * dist))){ // distance with lca ans = min(ans, mp[v][k - (it.fi - 2 * dist)] + it.se - 2 * dep); } } for(auto &it : mp[u.fi]){ if(!mp[v].count(it.fi)) mp[v][it.fi] = it.se; else mp[v][it.fi] = min(mp[v][it.fi], it.se); if(it.fi - dist == k){ ans = min(ans, it.se - dep); } } } } int32_t best_path(int32_t n, int32_t K, int32_t h[][2], int32_t l[]){ k = K; vector<vector<pii>> adj(n); for(int i = 0; i < n; i++){ adj[h[i][0]].emplace_back(h[i][1], l[i]); adj[h[i][1]].emplace_back(h[i][0], l[i]); } dfs(adj); return (ans == LLONG_MAX ? -1 : ans); }

Compilation message (stderr)

race.cpp: In function 'void dfs(std::vector<std::vector<std::pair<long long int, long long int> > >&, i64, i64, i64, i64)':
race.cpp:21:18: error: cannot convert 'std::pair<long long int, long long int>' to 'i64' {aka 'long long int'}
   21 |         dfs(adj, u, v, dist + u.se, dep + 1);
      |                  ^
      |                  |
      |                  std::pair<long long int, long long int>
race.cpp:18:47: note:   initializing argument 2 of 'void dfs(std::vector<std::vector<std::pair<long long int, long long int> > >&, i64, i64, i64, i64)'
   18 | inline void dfs(vector<vector<pii>> &adj, int v = 0, int p = -1, int dist = 0, int dep = 0){
      |                                               ^