#include<bits/stdc++.h>
//#include "cyberland.h"
using namespace std;
using ll = long long int;
vector<pair<ll,ll>> G[100002];
set<pair<ll,ll>> now_node;
ll dis[100002];
int vis[100002]={0};
double solve(int N,int M,int K,int H, vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
int n=N,m=M;
for(int i=0;i<=n;i++){
vis[i]=0;
dis[i]=100000000000000;
G[i].clear();
}
for(int i=0;i<m;i++){
G[x[i]].push_back(make_pair(c[i],y[i]));
G[y[i]].push_back(make_pair(c[i],x[i]));
}
dis[0]=0;
vis[0]=1;
for(auto i:G[0]){
dis[i.second]=dis[0]+i.first;
now_node.insert(i);
}
dis[0]=0;
while((int)now_node.size()){
auto it = *now_node.begin();
if(!vis[it.second]){
vis[it.second]=1;
for(auto now:G[it.second]){
if(dis[now.second]>dis[it.second]+now.first){
dis[now.second]=dis[it.second]+now.first;
now_node.insert(make_pair(dis[now.second],now.second));
}
}
}
now_node.erase(it);
}
cout << dis[H];
return (double)dis[H];
}
/*
int main(){
int T;
cin>>T;
for(int s=0;s<T;s++){
int N,M,K,H;
cin>>N>>M>>K>>H;
vector<int> x,y,c,arr;
for(int i=0;i<N;i++){
int tmp;
cin>>tmp;
arr.push_back(tmp);
}
for(int i=0;i<M;i++){
int tmp1,tmp2,tmp3;
cin>>tmp1>>tmp2>>tmp3;
x.push_back(tmp1);
y.push_back(tmp2);
c.push_back(tmp3);
}
cout << solve(N,M,K,H,x,y,c,arr) << "\n";
}
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
2844 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
2780 KB |
Double 2.89051e+19 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
2796 KB |
Double 1.58048e+19 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
7788 KB |
Double 6.983e+25 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
2948 KB |
Double 2.58721e+19 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
2876 KB |
Double 3.1956e+19 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
2900 KB |
Double 1e+29 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
2884 KB |
Double 1e+29 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |