이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector<vector<pair<int,int>>>adj(N);
for (int i = 0;i<M;++i){
adj[x[i]].push_back({y[i],c[i]});
adj[y[i]].push_back({x[i],c[i]});
}
queue<pair<int,int>>q;
q.push({0,K});
vector<vector<double> >dist(N,vector<double>(K + 1,1e12));
dist[0][K] = 0;
while(!q.empty()){
auto u = q.front();
q.pop();
if (u.first == H)continue;
for (auto x:adj[u.first]){
long long v = x.second;
if (arr[x.first] == 0) v = -dist[u.first][u.second];
if (dist[x.first][u.second] > dist[u.first][u.second] + v){
dist[x.first][u.second] = dist[u.first][u.second] + v;
q.push({x.first,u.second});
}
if (arr[x.first] == 2 && u.second > 0){
if (dist[x.first][u.second - 1] > (dist[u.first][u.second] + x.second)/2){
dist[x.first][u.second - 1] = (dist[u.first][u.second] + x.second)/2;
q.push({x.first,u.second - 1});
}
}
}
}
double ans = 1e12;
for (int i = 0;i<=K;++i) ans = min(ans,dist[H][i]);
if (ans == 1e12) return -1;
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... |