Submission #1073825

# Submission time Handle Problem Language Result Execution time Memory
1073825 2024-08-24T22:51:12 Z ssitaram Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
251 ms 64408 KB
#include <bits/stdc++.h>
using namespace std;

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) {
		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;
	vector<priority_queue<int>> best2(n);
	for (int i = 0; i < k; ++i) {
		pq.push({0, p[i]});
		best2[p[i]].push(0);
		best2[p[i]].push(0);
	}
	while (!pq.empty()) {
		pair<int, int> state = pq.top();
		pq.pop();
		if (state.first > best2[state.second].top()) continue;
		if (!state.second) {
			return state.first;
		}
		for (pair<int, int>& edge : adj[state.second]) {
			if (best2[edge.first].size() < 2) {
				best2[edge.first].push(state.first + edge.second);
				if (best2[edge.first].size() == 2) pq.push({best2[edge.first].top(), edge.first});
			} else if (state.first + edge.second < best2[edge.first].top()) {
				best2[edge.first].pop();
				best2[edge.first].push(state.first + edge.second);
				pq.push({best2[edge.first].top(), edge.first});
			}
		}
	}
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4528 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4528 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4552 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4528 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4552 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 233 ms 57292 KB Output is correct
17 Correct 52 ms 20896 KB Output is correct
18 Correct 54 ms 20560 KB Output is correct
19 Correct 251 ms 64408 KB Output is correct
20 Correct 168 ms 47956 KB Output is correct
21 Correct 26 ms 10776 KB Output is correct
22 Incorrect 188 ms 47696 KB Output isn't correct
23 Halted 0 ms 0 KB -