/**
* author: AgentPengin ( Độc cô cầu bại )
* created: 23.12.2022 10:08:02
* too lazy to update time
**/
#include "crocodile.h"
#include<bits/stdc++.h>
#define EL '\n'
#define fi first
#define se second
#define NAME "TASK"
#define ll long long
#define lcm(a,b) (a/gcd(a,b))*b
#define db(val) "["#val" = " << (val) << "] "
#define bend(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
#define ex exit(0)
#define pii pair<int,int>
using namespace std;
const ll mod = 1e9 + 7;
const int inf = 0x1FFFFFFF;
const int MAXN = 1e5 + 5;
int n,m,k;
pair<int,int> dist[MAXN];
vector<pair<int,int>> adj[MAXN];
priority_queue<pii,vector<pii>,greater<pii>> pq;
int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]) {
n = N;
m = M;
for (int i = 0;i < m;i++) {
int u = R[i][0],v = R[i][1],l = W[i];
adj[u].emplace_back(v,l);
adj[v].emplace_back(u,l);
}
k = K;
for (int i = 0;i < k;i++) {
int u = E[i];
pq.push(make_pair(0,u));
dist[u] = make_pair(0,0);
}
while(!pq.empty()) {
int u = pq.top().se;
int du = pq.top().fi;
pq.pop();
if (du != dist[u].se) continue;
for (auto it : adj[u]) {
int v = it.fi;
int uv = it.se;
if (dist[v].fi > du + uv) {
if (dist[v].se > dist[v].fi) dist[v].se = dist[v].fi;
dist[v].fi = du + uv;
pq.push({dist[v].se,v});
} else {
if (du + uv < dist[v].se) {
dist[v].se = du + uv;
pq.push({dist[v].se,v});
}
}
}
}
return dist[0].se;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |