Submission #753718

# Submission time Handle Problem Language Result Execution time Memory
753718 2023-06-05T18:21:40 Z nicksms Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
1376 ms 99980 KB
/**
 *      Author:  Nicholas Winschel
 *      Created: 05.09.2023 19:37:01
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using db=long double;
template<class T> using V=vector<T>;
using vi = V<int>;
using vl = V<ll>;
using pi = pair<int,int>;
using pl = pair<ll, ll>;
#define f first
#define s second
#define sz(x) (int)((x).size())

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	V<multiset<ll>> ts(N);
	priority_queue<pl, V<pl>, greater<pl>> h;
	V<bool> vis(N);
	V<ll> best(N);
	V<V<pi>> adj(N);
	for (int i = 0; i < M; i++) {
		adj[R[i][0]].emplace_back(R[i][1], i);
		adj[R[i][1]].emplace_back(R[i][0], i);
	}
	for (int i = 0; i < K; i++) {
		ts[P[i]].insert(0); ts[P[i]].insert(0);
		h.emplace(0, P[i]);
	}
	while (sz(h)) {
		auto p = h.top();
		h.pop();
		if (vis[p.s]) continue;
		vis[p.s]=true;
		best[p.s]=p.f;
		for (pi e : adj[p.s]) {
			if (vis[e.f]) continue;
			ts[e.f].insert(L[e.s]+best[p.s]);
			if (sz(ts[e.f])>=2) h.emplace(*(++ts[e.f].begin()), e.f);
		}
	}

	return best[0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 6 ms 1320 KB Output is correct
13 Correct 5 ms 1364 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 6 ms 1320 KB Output is correct
13 Correct 5 ms 1364 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 572 KB Output is correct
16 Correct 1376 ms 94104 KB Output is correct
17 Correct 85 ms 25620 KB Output is correct
18 Correct 133 ms 26916 KB Output is correct
19 Correct 1318 ms 99980 KB Output is correct
20 Correct 581 ms 89412 KB Output is correct
21 Correct 45 ms 11404 KB Output is correct
22 Correct 562 ms 74536 KB Output is correct