이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fst first
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i < b; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n';
#define pi pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
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]=0;
pq.push({0,H-1});
while(!pq.empty()){
std::pair<int,int> nd = pq.top();
nd.first*=-1;
pq.pop();
if(nd.second==H) return nd.first;
//std::cout<<nd.second<<" "<<nd.first<<" "<<(int)adj[nd.second].size()<<'\n';
//if(dist[nd.second]<=nd.first) continue;
for(int i = 0; i < (int)adj[nd.second].size(); i++){
//std::cout<<"Costo:"<<nd.first+adj[nd.second][i].second<<'\n';
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;
}
}
}
return -1;
}
/*
int main(){
int N;
int M;
int K;
int H;
std::cin>>N>>M>>K>>H;
std::vector<int> x(M);
std::vector<int> y(M);
std::vector<int> c(M);
std::vector<int> arr(N);
for(int i = 0; i < M; i++){
std::cin>>x[i];
}
for(int i = 0; i < M; i++){
std::cin>>y[i];
}
for(int i = 0; i < M; i++){
std::cin>>c[i];
}
for(int i = 0; i < M; i++){
std::cin>>arr[i];
}
std::cout<<solve(N,M,K,H,x,y,c,arr)<<'\n';
return 0;
}*/
# | 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... |