This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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) {
int n=N, m=M, k=K, h=H;
if(n>3){
return -1;
}
if(h==0) return 0;
vector<vector<double>> ct(n, vector<double> (n, -1));
for(int i=0; i<m; i++){
ct[x[i]][y[i]]=c[i];
ct[y[i]][x[i]]=c[i];
}
double res=-1;
if(ct[0][h]>=0){
res=ct[0][h];
}
if(n<3) return res;
if(ct[0][3-h]>=0 && ct[3-h][h]>=0){
if(arr[3-h]==1){
if(res<-0.5){
res=ct[0][3-h]+ct[3-h][h];
}
else{
res=min(res, ct[0][3-h]+ct[3-h][h]);
}
}
else if(arr[3-h]==0){
if(res<-0.5){
res=ct[3-h][h];
}
else{
res=min(res, ct[3-h][h]);
}
}
else{
if(k>0){
if(res<-0.5){
res=(double)ct[0][3-h]/2+ct[3-h][h];
}
else{
res=min(res, (double)ct[0][3-h]/2+ct[3-h][h]);
}
}
else{
if(res<-0.5){
res=ct[0][3-h]+ct[3-h][h];
}
else{
res=min(res, ct[0][3-h]+ct[3-h][h]);
}
}
}
}
return res;
}
# | 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... |