#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
#define ff first
#define ss second
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector <pair<int,int>> v[n];
for(int i = 0; i < m; i++){
v[x[i]].push_back({y[i],c[i]});
v[y[i]].push_back({x[i],c[i]});
}
priority_queue <pair<double,pair<int,int>>> q;
vector <double> dis(n,1e9);
vector <int> dis1(n,k+1);
dis[0] = 0;
dis1[0] = 0;
q.push({0,{0,0}});
while(!q.empty()){
auto [ind,kcur] = q.top().ss;
double w = dis[ind];
// cout << w << ' ' << ind << ' ' << kcur << '\n';
q.pop();
if(h == ind) continue;
for(auto [i,j] : v[ind]){
// if(ind == 1){
// cout << "asd" << w << ' ' << i << ' ' << j << ' ' << arr[i] << '\n';
// }
if(arr[i] == 0){
w = 0;
if(kcur < dis1[i] or dis[i] > 0){
dis1[i] = min(dis1[i],kcur);
dis[i] = min(w,dis[i]);
// if(i == 1){
// cout << w << ' ' << i << ' ' << kcur << '\n';
// }
q.push({0,{i,kcur}});
}
}
else if(arr[i] == 2){
w += j;
double w1 = w;
if(kcur < k){
w /= 2;
kcur++;
if(kcur < dis1[i] or dis[i] > w){
dis[i] = min(w,dis[i]);
dis1[i] = min(dis1[i],kcur);
if(i == 1){
cout << w << ' ' << i << ' ' << kcur << '\n';
}
q.push({-w,{i,kcur}});
}
kcur--;
}
w = w1;
if(kcur < dis1[i] or dis[i] > w){
dis[i] = min(w,dis[i]);
dis1[i] = min(dis1[i],kcur);
q.push({-w,{i,kcur}});
// if(i == 1){
// cout << w << ' ' << i << ' ' << kcur << '\n';
// }
}
}
else {
w += j;
if(w < dis[i] or kcur < dis1[i]){
dis[i] = min(w,dis[i]);
dis1[i] = min(dis1[i],kcur);
// if(i == 1){
// cout << w << ' ' << i << ' ' << kcur << '\n';
// }
q.push({-w,{i,kcur}});
}
}
}
}
for(int i = 0; i < n; i++){
cout << dis[i] << ' ';
}
cout << '\n';
return dis[h];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
856 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
1620 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
1876 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
7764 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
1668 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
1820 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
1876 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
1876 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |