Submission #263363

# Submission time Handle Problem Language Result Execution time Memory
263363 2020-08-13T16:08:08 Z maximath_1 Crocodile's Underground City (IOI11_crocodile) C++11
100 / 100
1269 ms 59304 KB
#include "crocodile.h"
#include <vector>
#include <queue>
using namespace std;

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

	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
	for(int i = 0; i < K; i ++){
		pq.push({0, P[i]});
		dist[P[i]] = -69;
	}

	while(!pq.empty()){
		pair<int, int> nw = pq.top();
		pq.pop();

		if(dist[nw.second] >= 0) continue;
		if(dist[nw.second] == -1){
			dist[nw.second] = -69;
			continue;
		}

		dist[nw.second] = nw.first;

		for(pair<int, int> nx : adj[nw.second])
			pq.push({nw.first + nx.second, nx.first});
	}

	return dist[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2688 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2688 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 6 ms 3072 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 9 ms 3488 KB Output is correct
13 Correct 10 ms 3584 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2688 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 6 ms 3072 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 9 ms 3488 KB Output is correct
13 Correct 10 ms 3584 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
16 Correct 1143 ms 56744 KB Output is correct
17 Correct 107 ms 10640 KB Output is correct
18 Correct 146 ms 12052 KB Output is correct
19 Correct 1269 ms 59304 KB Output is correct
20 Correct 748 ms 53572 KB Output is correct
21 Correct 61 ms 6648 KB Output is correct
22 Correct 642 ms 32820 KB Output is correct