이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |