Submission #420035

#TimeUsernameProblemLanguageResultExecution timeMemory
420035OzyDreaming (IOI13_dreaming)C++17
14 / 100
79 ms24132 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl #define des first #define val second lli act,res; lli visitados[100002],MIN[2]; vector<pair<lli,lli> > hijos[100002],caminos[100002]; lli DSF(lli pos, lli padre) { lli tiem = 0; lli a = 0; lli k = 0; visitados[pos] = 1; for (auto h : hijos[pos]) { if (h.des == padre) {tiem = h.val;continue;} a = DSF(h.des,pos); caminos[pos].push_back({h.des,a}); if (a > k) k = a; } return a + tiem; } void optimo(lli pos, lli padre, lli suma) { lli dd,prim = 0; lli a,seg = 0; for (auto h : caminos[pos]) { if (h.val > prim){ seg = prim; prim = h.val; dd = h.des; } else if (h.val > seg) seg = h.val; } a = max(prim,suma); if (a < MIN[act]) MIN[act] = a; a = prim + seg; if (a > res) res = a; for (auto h : hijos[pos]) { if (h.des == padre) continue; if (h.des == dd) optimo(h.des,pos,(max(suma,seg)+h.val)); else optimo(h.des,pos,(max(suma,prim)+h.val)); } } void procesa(lli pos) { lli a = DSF(pos,0); optimo(pos,0,0); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { rep(i,0,M-1) { hijos[A[i]].push_back({B[i],T[i]}); hijos[B[i]].push_back({A[i],T[i]}); } act = 0; res = 0; MIN[0] = 1ll<<62; MIN[1] = 1ll<<62; rep(i,1,N) { if (act == 2) break; if (visitados[i] == 0) { procesa(i); act++; } } act = MIN[0] + MIN[1] + L; res = max(res,act); return res; }

Compilation message (stderr)

dreaming.cpp: In function 'void procesa(long long int)':
dreaming.cpp:61:9: warning: unused variable 'a' [-Wunused-variable]
   61 |     lli a = DSF(pos,0);
      |         ^
dreaming.cpp: In function 'void optimo(long long int, long long int, long long int)':
dreaming.cpp:54:9: warning: 'dd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |         if (h.des == dd) optimo(h.des,pos,(max(suma,seg)+h.val));
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...