제출 #981904

#제출 시각아이디문제언어결과실행 시간메모리
981904alo_54사이버랜드 (APIO23_cyberland)C++17
0 / 100
23 ms6988 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; struct Arista { int v, p; }; struct Nodo { vector <Arista> ady; int ability; }; vector <Nodo> g; vector <Arista> padre; vector <bool> vis; int h; bool alcanzado; void clean(int N) { g.clear(); padre.clear(); alcanzado = false; vis.clear(); g.resize(N); padre.resize(N); vis.resize(N, false); } void dfs(int nodo, int pe) { if (nodo == h) { alcanzado = true; return; } for (auto i : g[nodo].ady) { if (!vis[i.v]) { padre[i.v] = {nodo, i.p}; vis[i.v] = true; dfs(i.v, nodo); } } } 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) { h = H; clean(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]; } vis[0] = true; padre[0] = {-1, 0}; dfs(0, 0); if (alcanzado) { int cost = 0; int curr = H; while (curr != -1) { cost += padre[curr].p; curr = padre[curr].v; } return cost; } return -1; } /* 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; } } */
#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...