#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pdi pair<double,pii>
#define fi first
#define se second
double solve(int N, int M, int K, int T, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
K=min(K,100);
vector<vector<double>> dist(N,vector<double>(K+1,1e14));
vector<vector<pii>> edge(N);
for(int i=0;i<M;i++){
edge[x[i]].push_back({y[i],c[i]});
edge[y[i]].push_back({x[i],c[i]});
}
priority_queue<pdi,vector<pdi>,greater<pdi>> pq;
dist[0][0]=0;pq.push({0,{0,0}});
while(!pq.empty()){
auto [d,x]=pq.top();pq.pop();
int u=x.fi,k=x.se;
if(u==T) return d;
if(k==K) continue;
for(auto [v,w]:edge[u]){
double nd=(dist[u][k]+w)*(arr[v]?1.0/arr[v]:0);
int nk=k+(arr[v]==2);
if(dist[v][nk]>nd){
dist[v][nk]=nd;
pq.push({nd,{v,nk}});
}
if(dist[u][k]+w<dist[v][k]){
dist[v][k]=dist[u][k]+w;
pq.push({dist[u][k]+w,{v,k}});
}
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
468 KB |
Correct. |
2 |
Correct |
19 ms |
468 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
664 KB |
Correct. |
2 |
Correct |
27 ms |
696 KB |
Correct. |
3 |
Correct |
26 ms |
700 KB |
Correct. |
4 |
Correct |
27 ms |
708 KB |
Correct. |
5 |
Correct |
30 ms |
688 KB |
Correct. |
6 |
Correct |
21 ms |
3860 KB |
Correct. |
7 |
Correct |
34 ms |
3864 KB |
Correct. |
8 |
Correct |
16 ms |
7508 KB |
Correct. |
9 |
Correct |
27 ms |
340 KB |
Correct. |
10 |
Correct |
27 ms |
392 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
672 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
151 ms |
21196 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
700 KB |
Correct. |
2 |
Correct |
29 ms |
664 KB |
Correct. |
3 |
Correct |
27 ms |
720 KB |
Correct. |
4 |
Correct |
26 ms |
3668 KB |
Correct. |
5 |
Correct |
24 ms |
412 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
716 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
228 ms |
1096 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
861 ms |
3184 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |