제출 #1126271

#제출 시각아이디문제언어결과실행 시간메모리
1126271psm9352사이버랜드 (APIO23_cyberland)C++20
8 / 100
1558 ms2162688 KiB
#include <vector> #include <queue> using namespace std; void dfs(int par,int node, vector<vector<pair<int,double>>> &graph,vector<double> &ans,vector<int> &arr){ for (pair<int,double> next:graph[node]){ if (next.first==par){continue;} if (arr[next.first]==0){ans[next.first]=0;} else{ans[next.first]=ans[node]+next.second;} dfs(node,next.first,graph,ans,arr); } } double solve(int N, int M, int K, int H, vector<int> x, vector<int>y, vector<int> c, vector<int> arr){ vector<vector<pair<int,double>>> graph(N); for (int i = 0;i<M;i++){ graph[x[i]].push_back({y[i],c[i]}); graph[y[i]].push_back({x[i],c[i]}); } vector<double> ans(N,1e18);ans[0]=0; vector<bool> visited(N,0); dfs(-1,0,graph,ans,arr); if (ans[H]>=1e18){return -1;} return ans[H]; }
#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...