#include "cyberland.h"
#include <vector>
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
typedef long long ll;
const ll MAX_DIST=LONG_LONG_MAX;
using namespace std;
int n,m,k,h;
vector<pair<int,ll>>nodes[100000];
ll dist[100000];
double solve(int N,int M,int K,int H,vector<int>x,vector<int>y,vector<int>c,vector<int>arr){
n=N;
m=M;
k=K;
h=H;
for(int i=0;i<n;i++){
nodes[i].clear();
dist[i]=MAX_DIST;
}
for(int i=0;i<m;i++){
nodes[x[i]].emplace_back(y[i],c[i]);
nodes[y[i]].emplace_back(x[i],c[i]);
}
dist[0]=MAX_DIST;
queue<int>q;
q.push(0);
while(!q.empty()){
int curr=q.front();
q.pop();
for(pair<int,ll>ne:nodes[curr]){
ll new_dist=dist[curr]+ne.second;
if(new_dist<dist[ne.first]){
dist[ne.first]=new_dist;
q.push(ne.first);
}
}
}
ll res=dist[h];
if(res==MAX_DIST)
res=-1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
2964 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
3168 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3660 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
8576 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
3720 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
3692 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
3832 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
3516 KB |
Double -9.22337e+18 violates the range [-1, 1e+18] |
2 |
Halted |
0 ms |
0 KB |
- |