이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5, kx=71;
priority_queue<pair<double, pair<int, int>>, vector<pair<double, pair<int, int>>>, greater<pair<double, pair<int, int>>>> pq;
double dp[nx][kx], ans=DBL_MAX;
//bool vs[nx][kx];
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<vector<pair<int, int>>> d(nx);
K=min(K, 70);
for (int i=0; i<M; i++) d[x[i]].push_back({y[i], c[i]}), d[y[i]].push_back({x[i], c[i]});
for (int i=0; i<N; i++) for (int j=0; j<=K; j++) dp[i][j]=DBL_MAX; //vs[i][j]=0;
dp[0][0]=0;
pq.push({0, {0, 0}});
while (!pq.empty())
{
double cw=pq.top().first;
int ck=pq.top().second.first, cl=pq.top().second.second;
pq.pop();
//vs[cl][ck]=1;
if (cl==H) continue;
for (auto [v, w]:d[cl])
{
//if (vs[cl][ck]) continue;
if (arr[v]==0&&dp[v][0]==DBL_MAX) pq.push({0, {0, v}}), dp[v][0]=0;
if (dp[v][ck]>cw+w) pq.push({cw+w, {ck, v}}), dp[v][ck]=cw+w;
if (arr[v]==2&&ck!=K) if (dp[v][ck+1]>(cw+w)/2) pq.push({(cw+w)/2, {ck+1, v}}), dp[v][ck+1]=(cw+w)/2;
}
}
ans=DBL_MAX;
for (int i=0; i<=K; i++) ans=min(ans, dp[H][i]);
if (ans==DBL_MAX) 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... |