이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |