Submission #392938

# Submission time Handle Problem Language Result Execution time Memory
392938 2021-04-22T10:35:34 Z Aryan_Raina Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
645 ms 72796 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define ar array
#define ll long long
const ll INF = 1e15;
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
	vector<ar<ll,2>> g[n];

	for (ll i = 0; i < m; i++) {
		g[R[i][0]].push_back({L[i], R[i][1]});
		g[R[i][1]].push_back({L[i], R[i][0]});
	}

	vector<ll> d1(n, INF), d2(n, INF);
	priority_queue<ar<ll,2>, vector<ar<ll,2>>, greater<ar<ll,2>>> pq;
	for (ll i = 0; i < k; i++) pq.push({d1[P[i]] = d2[P[i]] = 0, P[i]});

	vector<bool> vis(n, false);
	while (!pq.empty()) {
		ll u = pq.top()[1], dist = pq.top()[0]; pq.pop();
		if (vis[u]) continue;
		vis[u] = true;
		for (auto v : g[u]) {
			if (dist + v[0] < d1[v[1]]) d2[v[1]] = d1[v[1]], d1[v[1]] = dist + v[0];
			else if (dist + v[0] < d2[v[1]]) d2[v[1]] = dist + v[0];
			else continue;
			if (d2[v[1]] <= INF/2) pq.push({d2[v[1]], v[1]});
		}
	}
	return d2[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 5 ms 844 KB Output is correct
13 Correct 5 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 5 ms 844 KB Output is correct
13 Correct 5 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 516 ms 65336 KB Output is correct
17 Correct 85 ms 14380 KB Output is correct
18 Correct 112 ms 16580 KB Output is correct
19 Correct 645 ms 72796 KB Output is correct
20 Correct 324 ms 52684 KB Output is correct
21 Correct 41 ms 6664 KB Output is correct
22 Correct 353 ms 48192 KB Output is correct