Submission #976618

#TimeUsernameProblemLanguageResultExecution timeMemory
976618rakhim_ovaCyberland (APIO23_cyberland)C++17
5 / 100
17 ms2140 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...