이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cyberland.h"
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
const int N = 1e5+5;
const int K = 30+2;
vector<pair<int,int> > g[N];
long double dist[N][K];
bool vis[N][K];
int type[N];
double solve(int n, int m, int k, int h, vector<int> x,
vector<int> y, vector<int> c, vector<int> arr)
{
for(int i = 0;i<m;i++)
g[x[i]].pb({y[i],c[i]}),
g[y[i]].pb({x[i],c[i]});
for(int i = 0;i<n;i++)
type[i]=arr[i];
for(int i = 0;i<n;i++)
for(int j = 0;j<=k;j++)
dist[i][j]=1e18,
vis[i][j]=0;
priority_queue<pair<long double,pair<int,int> >,vector<pair<long double,pair<int,int> > >,greater<pair<long double,pair<int,int> > > > q;
dist[0][0]=0;
q.push({0,{0,0}});
for(int i = 0;i<n;i++)
if(arr[i]==0)
dist[i][0]=0,
q.push({0,{i,0}});
for(int i = 0;i<=k;i++)
vis[h][i]=1;
while(!q.empty())
{
int u = q.top().se.fi, dv = q.top().se.se;
q.pop();
if(vis[u][dv])
continue;
vis[u][dv]=1;
for(auto v:g[u])
{
long double nwc = dist[u][dv]+v.se;
if(dist[v.fi][dv]>nwc)
dist[v.fi][dv]=nwc,
q.push({nwc,{v.fi,dv}});
if(arr[v.fi]==2&&dv<k)
{
nwc = (dist[u][dv]+v.se)/2;
if(dist[v.fi][dv+1]>nwc)
dist[v.fi][dv+1]=nwc,
q.push({nwc,{v.fi,dv+1}});
}
}
}
long double best = 1e18;
for(int i = 0;i<=k;i++)
best=min(best,dist[h][i]);
for(int i = 0;i<n;i++)
g[i].clear();
if(best==1e18)
return -1;
return best;
}
# | 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... |