#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
using pii = pair<int,int>;
const int mxN = (int)1e5+10;
const int INF = (int)1e9;
vector<int> exits;
vector<pii> adj[mxN];
int n, m, dis[mxN], dis2[mxN], vis[mxN];
int dijkstra(){
priority_queue<pii,vector<pii>,greater<pii>> pq;
memset(dis,63,sizeof(dis)); memset(dis2,63,sizeof(dis2));
for(auto u : exits) dis[u]=0, dis2[u]=0, pq.push({0,u});
while(!pq.empty()){
int s = pq.top().second; pq.pop();
if(vis[s]) continue; vis[s]=1;
for(auto cur : adj[s]){
int u = cur.first, w = cur.second;
if(dis2[u]>dis[s]+w)
dis2[u]=dis[s]+w, pq.push({dis2[u],u});
else if(dis[u]>dis[s]+w){
dis2[u]=dis[u], dis[u]=dis[s]+w;
pq.push({dis2[u],u});
}
}
}
return dis[0];
}
int travel_plan(int N, int M, int R[][2], int L[], int k, int p[])
{
n = N, m = M;
for(int i = 0; i < m; i++){
int a = R[i][0], b = R[i][1], c = L[i];
adj[a].pb({b,c}), adj[b].pb({a,c});
}
for(int i = 0; i < k; i++) exits.pb(p[i]);
return dijkstra();
}
Compilation message
crocodile.cpp: In function 'int dijkstra()':
crocodile.cpp:19:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
19 | if(vis[s]) continue; vis[s]=1;
| ^~
crocodile.cpp:19:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
19 | if(vis[s]) continue; vis[s]=1;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |