Submission #988207

# Submission time Handle Problem Language Result Execution time Memory
988207 2024-05-24T09:53:13 Z BF001 Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
463 ms 97728 KB
#include <bits/stdc++.h>
using namespace std;

#define NN 100005
#define oo 1e18
#define fi first
#define se second

typedef pair<long long, long long> ii;

int n, m, k;
long long d1[NN], d2[NN];
vector<int> sr;
vector<ii> adj[NN];

int ditra(){
	for (int i = 0; i <= n; i++) d1[i] = d2[i] = oo;
	priority_queue<ii, vector<ii>, greater<ii>> q;
	for (auto x : sr){
		d2[x] = d1[x] = 0;
		q.push({0, x});
	}
	while (!q.empty()){
		int u = q.top().se;
		int du = q.top().fi;
		q.pop();
		if (du != d2[u]) continue;
		for (auto x : adj[u]){
			int v = x.fi;
			int dv = x.se;
			if (du + dv < d1[v]){
				d2[v] = d1[v];
				d1[v] = du + dv;
				q.push({d2[v], v});
			}
			else if (du + dv < d2[v]){
				d2[v] = du + dv;
				q.push({d2[v], v});
			}
		}
	}
	return (int) d2[0];
}

int travel_plan(int N, int M , int R[][2], int L[], int k, int p[]){
	n = N;
	m = M;
	for (int i = 0; i < m; i++){
		int a = R[i][0], b = R[i][1], c = L[i];
		adj[a].push_back({b, c});
		adj[b].push_back({a, c}); 
	}
	for (int i = 0; i < k; i++){
		sr.push_back(p[i]);
	}
	return ditra();
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 2 ms 6760 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6784 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 3 ms 6744 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 2 ms 6760 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6784 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 3 ms 6744 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 4 ms 9052 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 5 ms 9308 KB Output is correct
13 Correct 4 ms 9436 KB Output is correct
14 Correct 2 ms 7004 KB Output is correct
15 Correct 3 ms 6764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 2 ms 6760 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6784 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 3 ms 6744 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 4 ms 9052 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 5 ms 9308 KB Output is correct
13 Correct 4 ms 9436 KB Output is correct
14 Correct 2 ms 7004 KB Output is correct
15 Correct 3 ms 6764 KB Output is correct
16 Correct 384 ms 90820 KB Output is correct
17 Correct 73 ms 24012 KB Output is correct
18 Correct 88 ms 26452 KB Output is correct
19 Correct 463 ms 97728 KB Output is correct
20 Correct 219 ms 72528 KB Output is correct
21 Correct 33 ms 17032 KB Output is correct
22 Incorrect 236 ms 69988 KB Output isn't correct
23 Halted 0 ms 0 KB -