#include "cyberland.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,double,int> trio;
const int MAXN = 2e5 + 5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
vector<double> dist[35];
vector<vector<pii>> edges(N);
vector<bool> vis(N);
for(int i = 0; i <= K; i++) dist[i].resize(N, 1e18);
for(int i = 0; i < M; i++) {
edges[x[i]].pb({y[i], c[i]});
edges[y[i]].pb({x[i], c[i]});
}
priority_queue<trio> pq;
pq.push({K, 0, 0});
queue<int> fila;
fila.push(0);
while(!fila.empty()) {
int x = fila.front();
fila.pop();
if(arr[x] == 0) pq.push({K, 0, x});
for(auto [viz, peso] : edges[x])
if(!vis[viz]) fila.push(viz), vis[viz] = 1;
}
for(int i = 0; i < N; i++) vis[i] = 0;
while(!pq.empty()) {
auto [k, D, at] = pq.top();
pq.pop();
D *= -1;
if(arr[at] == 0) D = 0;
if(vis[at]) continue;
vis[at] = 1;
if(at == H) continue;
for(auto [viz, peso] : edges[at]) {
if(D + peso < dist[k][viz])
pq.push({k, - D - peso, viz}), dist[k][viz] = D + peso;
if(k >= 1 and arr[at] == 2 and D/2 + peso < dist[k-1][viz])
pq.push({k-1, -D/2 -peso, viz}), dist[k-1][viz] = D/2 + peso;
}
}
double ans = 1e18;
for(int i = 0; i <= K; i++)
ans = min(ans, dist[i][H]);
if(ans == 1e18) return -1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
592 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1616 KB |
Correct. |
2 |
Correct |
22 ms |
848 KB |
Correct. |
3 |
Correct |
23 ms |
1616 KB |
Correct. |
4 |
Correct |
23 ms |
860 KB |
Correct. |
5 |
Correct |
41 ms |
840 KB |
Correct. |
6 |
Correct |
23 ms |
4432 KB |
Correct. |
7 |
Correct |
27 ms |
4688 KB |
Correct. |
8 |
Correct |
16 ms |
7504 KB |
Correct. |
9 |
Correct |
24 ms |
1372 KB |
Correct. |
10 |
Correct |
22 ms |
1360 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
1104 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
21552 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
736 KB |
Correct. |
2 |
Correct |
20 ms |
592 KB |
Correct. |
3 |
Correct |
23 ms |
944 KB |
Correct. |
4 |
Correct |
25 ms |
3376 KB |
Correct. |
5 |
Correct |
19 ms |
592 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
848 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
876 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1024 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |