Submission #919934

# Submission time Handle Problem Language Result Execution time Memory
919934 2024-02-01T21:27:31 Z Lobo Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
430 ms 83120 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define int long long
const int maxn = 1e5+10;
const int inf = 1e18+10;


int32_t travel_plan(int32_t n, int32_t m, int32_t R[][2], int32_t L[], int32_t k, int32_t P[])
{
	vector<vector<pair<int,int>>> g(n);
	for(int i = 0; i < m; i++) {
		g[R[i][0]].pb(mp(R[i][1],L[i]));
		g[R[i][1]].pb(mp(R[i][0],L[i]));
	}

	vector<int> d1(n),d2(n);
	for(int i = 0; i < n; i++) {
		d1[i] = d2[i] = inf;
	}
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	for(int i = 0; i < k; i++) {
		int v = P[i];
		d1[v] = d2[v] = 0;
		pq.push(mp(0,v));
	}

	while(pq.size()) {
		int u = pq.top().sc;
		int dis2 = pq.top().fr;
		pq.pop();
		if(dis2 != d2[u]) continue;

		for(auto V : g[u]) {
			int v = V.fr;
			int w = V.sc;
			if(d2[v] > d2[u]+w) {
				d2[v] = d2[u]+w;
				if(d2[v] < d1[v]) swap(d2[v],d1[v]);
				if(d2[v] != inf) pq.push(mp(d2[v],v));
			}
		}
	}

	return (int32_t) d2[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 2 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 2 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 2 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 2 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 2 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 344 ms 74724 KB Output is correct
17 Correct 57 ms 18256 KB Output is correct
18 Correct 78 ms 20636 KB Output is correct
19 Correct 430 ms 83120 KB Output is correct
20 Correct 224 ms 60160 KB Output is correct
21 Correct 28 ms 10792 KB Output is correct
22 Incorrect 265 ms 57532 KB Output isn't correct
23 Halted 0 ms 0 KB -