이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~LOTA~~~///
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 100000
#define K 31
int t;
int ab[N];
int vis[N];
double dp[N];
vector<pair<int,double>> a[N];
void dfs(int v){
if(vis[v] || v==t)
return;
vis[v]=1;
if(ab[v]==0)
dp[v]=0;
for(auto& i:a[v])
dfs(i.ff);
}
double solve(int n,int m,int k,int h,vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
t=h;
int p;
double q,r;
for(int i=0;i<n;i++){
ab[i]=arr[i];
dp[i]=-1e17;
}
for(int i=0;i<m;i++){
a[x[i]].append({y[i],c[i]});
a[y[i]].append({x[i],c[i]});
}
dfs(0);
r=1e17;
priority_queue<pair<double,int>> Q[K];
for(int j=dp[0]=0;j<=k;j++){
for(int i=0;i<n;i++){
Q[j].push({dp[i],i});
vis[i]=0;
}
while(!Q[j].empty()){
p=Q[j].top().ss;
q=Q[j].top().ff;
Q[j].pop();
if(!vis[p]){
vis[p]=1;
if(p==h){
r=min(r,-q);
continue;
}
dp[p]=q;
for(auto& i:a[p]){
if(arr[i.ff]==2 && j<k)
Q[j+1].push({(q-i.ss)/2,i.ff});
if(!vis[i.ff])
Q[j].push({q-i.ss,i.ff});
}
}
}
}
if(r==1e17) r=-1;
return r;
}
# | 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... |