This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
}
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 + caux/(double)2, minH);
}
}
}
if (!alcanzado)
{
return -1;
}else
{
return minH;
}
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |