이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
struct ari{
int node;
double cnt;
};
vector<vector<ari>> adj;
int state[100000];
int n, m, k, fin;
double ans;
void dfs(int node, double cnt, int ant){
if(node==fin){
if(ans==(1<<30))
ans=cnt;
else
ans=min(ans, cnt);
return;
}
for(auto h: adj[node]){
if(h.node==ant)
continue;
if(state[node]==0)
dfs(h.node, h.cnt, node);
else
dfs(h.node, cnt+h.cnt, node);
}
}
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) {
n=N; m=M; k=K; fin=H;
adj.clear();
adj.resize(n);
ans=(1<<30);
for(int i=0; i<m; i++){
adj[x[i]].push_back({y[i], (double)c[i]});
adj[y[i]].push_back({x[i], (double)c[i]});
}
for(int i=0; i<n; i++)
state[i]=arr[i];
dfs(0, 0, 0);
return ans;
}
# | 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... |