Submission #103239

#TimeUsernameProblemLanguageResultExecution timeMemory
103239dimash241Dreaming (IOI13_dreaming)C++17
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> #define _USE_MATH_DEFINES_ #define ll long long #define ld long double #define Accepted 0 #define pb push_back #define mp make_pair #define sz(x) (int)(x.size()) #define every(x) x.begin(),x.end() #define F first #define S second #define For(i,x,y) for (ll i = x; i <= y; i ++) #define FOr(i,x,y) for (ll i = x; i >= y; i --) #define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) // ROAD to... Red using namespace std; const double eps = 0.000001; const ld pi = acos(-1); const int maxn = 1e7 + 9; const int mod = 1e9 + 7; const ll MOD = 1e18 + 9; const ll INF = 1e18 + 123; const int inf = 2e9 + 11; const int mxn = 1e6 + 9; const int N = 6e5 + 123; const int M = 22; const int pri = 997; const int Magic = 2101; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; vector < int > comp; vector < pair < int, int > > g[N]; int n, m, k; int u[N]; int p[N]; int col; int dp[N]; int h[N]; int ans; void dfs (int v, int par = 0) { u[v] = 1; comp.pb(v); for (auto to : g[v]) { if (to.F != par) { h[to.F] = h[v] + to.S; p[to.F] = v; dfs(to.F, v); } } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { n = N, m = M, k = L; for (int i = 1; i <= m; i ++) { int l, r, x; l = A[i - 1], r = B[i - 1], x = T[i - 1]; g[l].pb(mp(r, x)); g[r].pb(mp(l, x)); } int ans = 0; vector < int > vv; for (int i = 0; i < n; i ++) { if (!u[i]) { col ++; p[i] = -1; comp.clear(); h[i] = 0; dfs (i); int mx = i; for (auto e : comp) if (h[e] > h[mx]) mx = e; p[mx] = -1; comp.clear(); h[mx] = 0; dfs(mx); for (auto e : comp) if (h[e] > h[mx]) mx = e; ans = max(ans, h[mx]); //cout << mx << ' ' << h[mx] << '\n'; int half = h[mx]; for (int v = mx; ~v; v = p[v]) { half = min(half, max(h[v], abs(h[v] - h[mx]))); } vv.pb(half); } } sort(every(vv)); reverse(every(vv)); if (vv.size() >= 2) ans = max(ans, vv[0] + vv[1] + k); if (vv.size() >= 3) ans = max(ans, v[1] + v[2] + k * 2); return ans; }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:98:18: error: 'v' was not declared in this scope
   ans = max(ans, v[1] + v[2] + k * 2);
                  ^
dreaming.cpp:98:18: note: suggested alternative: 'vv'
   ans = max(ans, v[1] + v[2] + k * 2);
                  ^
                  vv