#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 50005
#define MAX_M 1000005
#define pii pair<int,int>
const int INF = 2e9+5;
vector<pair<int,int>> adj[MAX_N];
int N, M, R[MAX_M][2], L[MAX_M], K, P[MAX_N];
int vis[MAX_N] = {0};
priority_queue<pii, vector<pii>, greater<pii>> pq;
int dist[MAX_N] = {0};
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0; i < K; ++i) {
vis[P[i]] = 2;
}
for(int i = 0; i < M; ++i) {
int a = R[i][0], b = R[i][1];
if(!(vis[a] == 2 && vis[b] == 2)) {
if(!(vis[a] == 2)) swap(a, b);
if(vis[a] == 2) pq.emplace(L[i], b);
}
adj[R[i][0]].emplace_back(R[i][1], L[i]);
adj[R[i][1]].emplace_back(R[i][0], L[i]);
}
while(!pq.empty()) {
int d = pq.top().first, u = pq.top().second;
pq.pop();
if(vis[u] == 2) continue;
else if(vis[u] == 1) {
vis[u] = 2;
dist[u] = d;
for(auto _ : adj[u]) {
int v = _.first, w = _.second;
if(vis[v] == 2) continue;
pq.emplace(d + w, v);
}
}
else vis[u] = 1;
}
return dist[0];
}
// int main() {
// ios_base::sync_with_stdio(0); cin.tie(0);
// int ans;
// cin >> N >> M >> K;
// for(int i = 0; i < M; ++i)
// cin >> R[i][0] >> R[i][1] >> L[i];
// for(int i = 0; i < K; ++i)
// cin >> P[i];
// ans = travel_plan(N,M,R,L,K,P);
// cout << ans;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
2 ms |
8792 KB |
Output is correct |
6 |
Correct |
2 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8660 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
2 ms |
8792 KB |
Output is correct |
6 |
Correct |
2 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8660 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
3 ms |
8708 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
5 ms |
9052 KB |
Output is correct |
13 |
Correct |
4 ms |
9052 KB |
Output is correct |
14 |
Correct |
2 ms |
8540 KB |
Output is correct |
15 |
Correct |
2 ms |
8672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
2 ms |
8792 KB |
Output is correct |
6 |
Correct |
2 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8660 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
3 ms |
8708 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
5 ms |
9052 KB |
Output is correct |
13 |
Correct |
4 ms |
9052 KB |
Output is correct |
14 |
Correct |
2 ms |
8540 KB |
Output is correct |
15 |
Correct |
2 ms |
8672 KB |
Output is correct |
16 |
Correct |
441 ms |
72380 KB |
Output is correct |
17 |
Runtime error |
53 ms |
24400 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |