제출 #984101

#제출 시각아이디문제언어결과실행 시간메모리
984101Rafiullah사이버랜드 (APIO23_cyberland)C++17
0 / 100
1203 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; 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> A) { int n ,m , k,h;cin>>n>>m>>k>>h; map<int,vector<int>> graph; map<pair<int,int>,int> weight; double dist[n]; for(int i = 0 ;i <n ;i ++){ dist[i] = 1e9; } for(int i = 0 ;i<m ;i ++){ int a = x[i]; int b = y[i]; int cc = c[i]; weight[{min(a,b),max(a,b)}] = cc; graph[a].push_back(b); graph[b].push_back(a); } priority_queue<pair<int,int>> pq; dist[0]=0; pq.push({0,0}); while(pq.size()>0){ int node = pq.top().second; pq.pop(); // cout<<graph[node].size()<<endl; for(int child:graph[node]){ int W = weight[{min(node,child),max(node,child)}]; // cout<<node<<" "<<child<<" "<<W<<endl; if(dist[node]+W<dist[child]){ dist[child] = dist[node]+W; pq.push({-dist[child],child}); } } } if(dist[h] == 1e9)dist[h] = -1; return dist[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...