Submission #1004490

# Submission time Handle Problem Language Result Execution time Memory
1004490 2024-06-21T09:24:45 Z vjudge3 Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
271 ms 61036 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> g[100005];
int di[100005][2];
const int inf = 2e9;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0; i < N; i++) di[i][0] = di[i][1] = inf;
	for (int i = 0; i < M; i++) {
		g[R[i][0]].push_back({R[i][1], L[i]});
		g[R[i][1]].push_back({R[i][0], L[i]});
	}
	using T = pair<int, int>;
	priority_queue<T, vector<T>, greater<T>> pq;
	for (int i = 0; i < K; i++) {
		pq.push({0, P[i]});
		di[P[i]][0] = di[P[i]][1] = 0;
	}
	while (!pq.empty()) {
		auto [d, u] = pq.top();
		pq.pop();
		if (di[u][1] != d) continue;
		for (auto& [v, w] : g[u]) {
			if (d+w <= di[v][0]) {
				di[v][1] = di[v][0];
				di[v][0] = d+w;
				if (di[v][1] != inf) pq.push({di[v][1], v});
			} else if (d+w < di[v][1]) {
				di[v][1] = d+w;
				pq.push({di[v][1], v});
			}
		}
	}
	return di[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2820 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2820 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2856 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Correct 3 ms 3232 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2820 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2856 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Correct 3 ms 3232 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 239 ms 57312 KB Output is correct
17 Correct 41 ms 13648 KB Output is correct
18 Correct 55 ms 15332 KB Output is correct
19 Correct 271 ms 61036 KB Output is correct
20 Correct 172 ms 49488 KB Output is correct
21 Correct 22 ms 7772 KB Output is correct
22 Incorrect 222 ms 45924 KB Output isn't correct
23 Halted 0 ms 0 KB -