Submission #228833

# Submission time Handle Problem Language Result Execution time Memory
228833 2020-05-02T18:25:22 Z staniewzki Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
640 ms 54884 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);
		}
	} 
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 560 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 10 ms 1024 KB Output is correct
13 Correct 11 ms 1152 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 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 560 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 10 ms 1024 KB Output is correct
13 Correct 11 ms 1152 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 599 ms 54884 KB Output is correct
17 Correct 105 ms 10104 KB Output is correct
18 Correct 114 ms 11384 KB Output is correct
19 Correct 640 ms 50660 KB Output is correct
20 Correct 395 ms 50768 KB Output is correct
21 Correct 55 ms 4472 KB Output is correct
22 Correct 628 ms 30708 KB Output is correct