#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ar = pair<double,int>;
const int mxN = (int)1e5+10;
const double LINF = 1e105;
double ans;
int n, m, h;
bool vis[mxN];
double dis[mxN], dis2[mxN];
vector<pair<int,int>> adj[mxN];
priority_queue<ar,vector<ar>,greater<ar>> pq;
void dijkstra(){
fill(vis,vis+n+1,0);
for(int i = 0; i < n; i++)
if(dis[i]<LINF) pq.push({dis[i],i});
while(!pq.empty()){
auto [D,a] = pq.top(); pq.pop();
if(vis[a] or a==h) continue; vis[a]=1;
for(auto [b,w] : adj[a]) if(dis[b]>dis[a]+w)
dis[b]=dis[a]+w, pq.push({dis[b],b});
}
ans = min(ans, dis[h]);
}
double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi A) {
n = N, m = M, h = H, K = min(K, 67);
fill(dis,dis+n,LINF); ans = LINF;
for(int i = 0; i < n; i++) adj[i].clear();
for(int i = 0; i < m; i++)
adj[x[i]].push_back({y[i],c[i]}),
adj[y[i]].push_back({x[i],c[i]});
dis[0]=0; dijkstra(); if(dis[h]>=LINF) return -1;
for(int i = 0; i < n; i++)
if(dis[i]!=LINF) dis[i]=A[i]&&i?LINF:0;
for(int i = 0; i <= K; i++){
dijkstra(); fill(dis2,dis2+n,LINF);
for(int j = 0; j < n; j++)
for(auto [u,w] : adj[j])
if(A[u]>1) dis2[u]=min(dis2[u],(dis[j]+w)/2);
for(int j = 0; j < n; j++) dis[j]=dis2[j];
}
return ans;
}
Compilation message
cyberland.cpp: In function 'void dijkstra()':
cyberland.cpp:21:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
21 | if(vis[a] or a==h) continue; vis[a]=1;
| ^~
cyberland.cpp:21:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
21 | if(vis[a] or a==h) continue; vis[a]=1;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
2892 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
3148 KB |
Correct. |
2 |
Correct |
31 ms |
3644 KB |
Correct. |
3 |
Correct |
30 ms |
3644 KB |
Correct. |
4 |
Correct |
31 ms |
3664 KB |
Correct. |
5 |
Correct |
31 ms |
3744 KB |
Correct. |
6 |
Correct |
33 ms |
4364 KB |
Correct. |
7 |
Correct |
40 ms |
4396 KB |
Correct. |
8 |
Correct |
22 ms |
4792 KB |
Correct. |
9 |
Correct |
28 ms |
3360 KB |
Correct. |
10 |
Correct |
27 ms |
3444 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
3564 KB |
Correct. |
2 |
Correct |
31 ms |
3552 KB |
Correct. |
3 |
Correct |
32 ms |
3676 KB |
Correct. |
4 |
Correct |
31 ms |
3044 KB |
Correct. |
5 |
Correct |
30 ms |
3532 KB |
Correct. |
6 |
Correct |
8 ms |
3668 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
8820 KB |
Correct. |
2 |
Incorrect |
142 ms |
3580 KB |
Wrong Answer. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
3676 KB |
Correct. |
2 |
Correct |
25 ms |
3776 KB |
Correct. |
3 |
Correct |
25 ms |
3656 KB |
Correct. |
4 |
Correct |
29 ms |
4480 KB |
Correct. |
5 |
Correct |
20 ms |
3400 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
3616 KB |
Correct. |
2 |
Correct |
27 ms |
3612 KB |
Correct. |
3 |
Correct |
33 ms |
9824 KB |
Correct. |
4 |
Correct |
18 ms |
4052 KB |
Correct. |
5 |
Correct |
23 ms |
3564 KB |
Correct. |
6 |
Correct |
24 ms |
3436 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
91 ms |
3692 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
172 ms |
3548 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |