이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define ld long double
using namespace std;
ld ans1,ans2,path[100010];
vector<pair<ll,ld>> v[100010];
priority_queue<pair<ld,ll>> q;
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) {
if(N==2){
if(M>0) return c[0];
else return -1;
}
if(N==3){
bool p=false,q=false;
ll d;
for(int i=0;i<M;i++){
if((x[i]==0 && y[i]==H) || (x[i]==H && y[i]==0)){
p=true;
ans1=c[i];
}
else if(x[i]==0 || y[i]==0){
if(x[i]==0) d=y[i];
else d=x[i];
if(arr[d]==0) ans2=0;
else if(arr[d]==1 || (arr[d]==2 && K<1)) ans2=c[i];
else ans2=(ld)c[i]/2;
for(int j=0;j<M;j++){
if((x[j]==d && y[j]==H) || (x[j]==H && y[j]==d)){
q=true;
ans2+=c[j];
}
}
}
}
if(!p && !q) return -1;
if(!p) return ans2;
if(!q) return ans1;
return min(ans1,ans2);
}
for(int i=0;i<N;i++){
path[i]=(double)-1;
v[i].clear();
}
for(int i=0;i<M;i++){
v[x[i]].push_back({y[i],(ld)c[i]});
v[y[i]].push_back({x[i],(ld)c[i]});
}
q.push({(ld)0,0});
while(!q.empty()){
ld dist=q.top().ff;
ll a=q.top().ss;
q.pop();
if(a==H) return -1*dist;
if(path[a]!=(ld)-1) continue;
if(arr[a]==1) path[a]=-1*dist;
else path[a]=0;
for(pair<ll,ld> i:v[a]){
if(path[i.ff]==(ld)-1){
q.push({-1*path[a]-i.ss,i.ff});
}
}
}
return -1;
}
# | 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... |