Submission #981868

#TimeUsernameProblemLanguageResultExecution timeMemory
981868alo_54Cyberland (APIO23_cyberland)C++17
0 / 100
25 ms7740 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; struct Arista { int v, p; }; struct Nodo { vector <Arista> ady; int ability; }; double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { vector <Nodo> g(N); for (int i = 0; i < M; i++) { g[x[i]].ady.push_back({y[i], c[i]}); g[y[i]].ady.push_back({x[i], c[i]}); } for (int i = 0; i < N; i++) { g[i].ability = arr[i]; } if (N <= 3) { if (N == 2) { for (auto i : g[0].ady) { if (i.v == H) { return i.p; } } return -1; } double minH = 1e9 + 10; bool alcanzado = false; double cost = 0; int aux = -1; double caux = 0; for (auto i : g[0].ady) { if (i.v == H) { alcanzado = true; minH = min(minH, (double)cost + i.p); }else { aux = i.v; caux = (double) i.p; } } if (aux != -1) { for(auto i : g[aux].ady) { if (i.v != 0) { alcanzado = true; if (g[aux].ability == 0) { minH = min((double)i.p, minH); } if (g[aux].ability == 2) { minH = min((double)i.p + (double)(caux/(double)2), minH); } } } } if (!alcanzado) { return -1; }else { return minH; } } }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:23:22: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     vector <Nodo> g(N);
      |                      ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...