Submission #932017

#TimeUsernameProblemLanguageResultExecution timeMemory
932017TheComputer사이버랜드 (APIO23_cyberland)C++17
0 / 100
22 ms5724 KiB
#include <bits/stdc++.h> 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){ std::vector<std::vector<std::pair<int,int>>> adj(N); for(int i = 0; i < M; i++) adj[x[i]].push_back({y[i],c[i]}),adj[y[i]].push_back({x[i],c[i]}); std::vector<std::pair<double,int>> res; std::priority_queue<std::pair<int,int>> pq; std::vector<double> dist(N,(int)1e20); dist[H-1]=0; pq.push({0,H-1}); while(!pq.empty()){ std::pair<int,int> nd = pq.top(); nd.first*=-1; pq.pop(); for(int i = 0; i < (int)adj[nd.second].size(); i++){ if(dist[adj[nd.second][i].first]>nd.first+adj[nd.second][i].second){ dist[adj[nd.second][i].first] = nd.first+adj[nd.second][i].second; if(arr[adj[nd.second][i].first]==1&&adj[nd.second][i].first!=0) pq.push({(nd.first+adj[nd.second][i].second)*-1,adj[nd.second][i].first}); else res.push_back({nd.first+adj[nd.second][i].second,adj[nd.second][i].first}); } } } double r = (int)1e20; for(int i = 0; i < (int)res.size(); i++){ r=std::min(res[i].first,r); } return r; }
#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...