Submission #228832

# Submission time Handle Problem Language Result Execution time Memory
228832 2020-05-02T18:19:42 Z staniewzki Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
664 ms 70884 KB
#include<bits/stdc++.h>
using namespace std;
 
#include "crocodile.h"

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	vector<vector<pair<int, int>>> adj(N);
	for(int i = 0; i < M; i++) {
		int u = R[i][0], v = R[i][1];
		adj[u].emplace_back(v, L[i]);
		adj[v].emplace_back(u, L[i]);
	}

	vector<int> vis(N);
	priority_queue<pair<int, int>> Q;
	for(int i = 0; i < K; i++) {
		vis[P[i]]++;
		Q.emplace(0, P[i]);
	}

	while(!Q.empty()) {
		auto [d, v] = Q.top();
		Q.pop();
		if(vis[v]++ == 1) {
			if(v == 0) 
				return -d;
			for(auto &[u, w] : adj[v])
				Q.emplace(d - w, u);
		}
	} 
	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 416 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 416 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 416 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 8 ms 1280 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 416 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 416 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 8 ms 1280 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 654 ms 70884 KB Output is correct
17 Correct 107 ms 13304 KB Output is correct
18 Correct 121 ms 14840 KB Output is correct
19 Correct 664 ms 67024 KB Output is correct
20 Correct 406 ms 63708 KB Output is correct
21 Correct 56 ms 6016 KB Output is correct
22 Correct 643 ms 44788 KB Output is correct