Submission #220872

# Submission time Handle Problem Language Result Execution time Memory
220872 2020-04-09T06:56:12 Z spdskatr Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
690 ms 64396 KB
#include "crocodile.h"
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <functional>
#include <cstdio>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, int> entry;
typedef long long ll;

ll da[100005], db[100005];
int done[100005];
vector<pii> graph[100005];
priority_queue<entry, vector<entry>, greater<entry>> pq;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0; i < M; i++) {
		graph[R[i][0]].push_back({ R[i][1], L[i] });
		graph[R[i][1]].push_back({ R[i][0], L[i] });
	}
	for (int i = 0; i < N; i++) da[i] = db[i] = -1;
	for (int i = 0; i < K; i++) {
		da[P[i]] = db[P[i]] = 0;
		pq.push({ db[P[i]], P[i] });
	}
	while (!pq.empty()) {
		entry e = pq.top(); pq.pop();
		int u = e.se;
		if (done[e.se]) continue;
		done[e.se] = 1;
		for (pii p : graph[u]) {
			int v = p.fi, w = p.se;
			if (!done[v]) {
				if (da[v] == -1 || da[v] >= db[u] + w) {
					db[v] = da[v];
					da[v] = db[u] + w;
					if (db[v] != -1) pq.push({ db[v], v });
				} else if (db[v] == -1 || db[v] > db[u] + w) {
					db[v] = db[u] + w;
					pq.push({ db[v], v });
				}
			}
		}
	}
	return (int)db[0];
}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 6 ms 2816 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 6 ms 2816 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 9 ms 2944 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 10 ms 3200 KB Output is correct
13 Correct 11 ms 3200 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 6 ms 2816 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 9 ms 2944 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 10 ms 3200 KB Output is correct
13 Correct 11 ms 3200 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2816 KB Output is correct
16 Correct 525 ms 58608 KB Output is correct
17 Correct 97 ms 14968 KB Output is correct
18 Correct 112 ms 16480 KB Output is correct
19 Correct 690 ms 64396 KB Output is correct
20 Correct 330 ms 49784 KB Output is correct
21 Correct 47 ms 8056 KB Output is correct
22 Correct 368 ms 46524 KB Output is correct