Submission #502626

#TimeUsernameProblemLanguageResultExecution timeMemory
502626NintsiChkhaidzeDreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> #define s second #define f first #define pb push_back #define ll long long using namespace std; void dfs(int x,ll d,int par){ if (d > D) {I = x,D = d;} for (int j=0;j<v[x].size();j++){ int to = v[x][j].f,w = v[x][j].s; if (to == par) continue; dfs(to,d + w,x); } } ll upd(ll d1,ll d2){ ll d_new = min(max(d1 + l,d2),max(d1,d2 + l)); diameter = max(diameter,d1 + l + d2); return d_new; } int P(int x){ if (x == p[x]) return x; return p[x] = P(p[x]); } void dsu(int u,int v){ int up = P(u),vp = P(v); if (up == vp) return; if (up > vp) swap(up,vp); p[vp] = up; } int travelTime(int n, int m, int L, int A[], int B[], int T[]) { l = L; for (int i = 0; i < n; i++) p[i] = i,v[i].clear(),d[i] = 1e9; for (int i = 0; i < m; i++){ v[A[i]].pb({B[i],T[i]}); v[B[i]].pb({A[i],T[i]}); dsu(A[i],B[i]); } for (int i = 0; i < n; i++){ p[i] = P(i); D = 0; dfs(i,0,i); d[p[i]] = min(d[p[i]],D); if (!fix[p[i]]) fix[p[i]] = 1,vec.pb(p[i]); } D = 0; dfs(vec[0],0,vec[0]); D = 0; dfs(I,0,I); diameter = D; for (int i=1; i<vec.size(); i++) d[vec[i]] = upd(d[vec[i - 1]],d[vec[i]]); return diameter; }

Compilation message (stderr)

dreaming.cpp: In function 'void dfs(int, long long int, int)':
dreaming.cpp:10:10: error: 'D' was not declared in this scope
   10 |  if (d > D) {I = x,D = d;}
      |          ^
dreaming.cpp:10:14: error: 'I' was not declared in this scope
   10 |  if (d > D) {I = x,D = d;}
      |              ^
dreaming.cpp:11:17: error: 'v' was not declared in this scope
   11 |  for (int j=0;j<v[x].size();j++){
      |                 ^
dreaming.cpp:14:14: error: 'w' was not declared in this scope
   14 |   dfs(to,d + w,x);
      |              ^
dreaming.cpp: In function 'long long int upd(long long int, long long int)':
dreaming.cpp:18:26: error: 'l' was not declared in this scope
   18 |  ll d_new = min(max(d1 + l,d2),max(d1,d2 + l));
      |                          ^
dreaming.cpp:19:2: error: 'diameter' was not declared in this scope
   19 |  diameter = max(diameter,d1 + l + d2);
      |  ^~~~~~~~
dreaming.cpp: In function 'int P(int)':
dreaming.cpp:24:11: error: 'p' was not declared in this scope
   24 |  if (x == p[x]) return x;
      |           ^
dreaming.cpp:25:9: error: 'p' was not declared in this scope
   25 |  return p[x] = P(p[x]);
      |         ^
dreaming.cpp: In function 'void dsu(int, int)':
dreaming.cpp:31:2: error: 'p' was not declared in this scope; did you mean 'vp'?
   31 |  p[vp] = up;
      |  ^
      |  vp
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:34:2: error: 'l' was not declared in this scope
   34 |  l = L;
      |  ^
dreaming.cpp:36:3: error: 'p' was not declared in this scope
   36 |   p[i] = i,v[i].clear(),d[i] = 1e9;
      |   ^
dreaming.cpp:36:12: error: 'v' was not declared in this scope
   36 |   p[i] = i,v[i].clear(),d[i] = 1e9;
      |            ^
dreaming.cpp:36:25: error: 'd' was not declared in this scope
   36 |   p[i] = i,v[i].clear(),d[i] = 1e9;
      |                         ^
dreaming.cpp:39:3: error: 'v' was not declared in this scope
   39 |   v[A[i]].pb({B[i],T[i]});
      |   ^
dreaming.cpp:45:3: error: 'p' was not declared in this scope
   45 |   p[i] = P(i);
      |   ^
dreaming.cpp:46:3: error: 'D' was not declared in this scope
   46 |   D = 0;
      |   ^
dreaming.cpp:48:3: error: 'd' was not declared in this scope
   48 |   d[p[i]] = min(d[p[i]],D);
      |   ^
dreaming.cpp:49:8: error: 'fix' was not declared in this scope
   49 |   if (!fix[p[i]]) fix[p[i]] = 1,vec.pb(p[i]);
      |        ^~~
dreaming.cpp:49:33: error: 'vec' was not declared in this scope
   49 |   if (!fix[p[i]]) fix[p[i]] = 1,vec.pb(p[i]);
      |                                 ^~~
dreaming.cpp:52:2: error: 'D' was not declared in this scope
   52 |  D = 0;
      |  ^
dreaming.cpp:53:6: error: 'vec' was not declared in this scope
   53 |  dfs(vec[0],0,vec[0]);
      |      ^~~
dreaming.cpp:55:6: error: 'I' was not declared in this scope
   55 |  dfs(I,0,I);
      |      ^
dreaming.cpp:56:2: error: 'diameter' was not declared in this scope
   56 |  diameter = D;
      |  ^~~~~~~~
dreaming.cpp:59:3: error: 'd' was not declared in this scope
   59 |   d[vec[i]] = upd(d[vec[i - 1]],d[vec[i]]);
      |   ^