Submission #954095

# Submission time Handle Problem Language Result Execution time Memory
954095 2024-03-27T09:20:06 Z 4QT0R Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
354 ms 68296 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>

struct edge{
	int to;
	int cost;
};

vector<edge> graph[100003];
pll odl[100003];
ll oo=1e18+1;

priority_queue<pll,vector<pll>,greater<pll>> pq;

void Dijkstra(){
	while(pq.size()){
		auto [d,v]=pq.top();
		pq.pop();
		if (odl[v].second<d)continue;
		for (auto u : graph[v]){
			if (d+u.cost<odl[u.to].first){
				odl[u.to].second=odl[u.to].first;
				if (odl[u.to].second<oo)pq.push(make_pair(odl[u.to].second,u.to));
				odl[u.to].first=d+u.cost;
			}
			else if (d+u.cost<odl[u.to].second){
				odl[u.to].second=d+u.cost;
				pq.push(make_pair(odl[u.to].second,u.to));
			}
		}
	}
}

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]});
	}
	fill(odl,odl+n,make_pair(oo,oo));
	for (int i = 0; i<k; i++){
		pq.push({0,p[i]});
		odl[p[i]]={0,0};
	}
	Dijkstra();
	return odl[0].second;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 8792 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 4 ms 9052 KB Output is correct
13 Correct 4 ms 9172 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 8792 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 4 ms 9052 KB Output is correct
13 Correct 4 ms 9172 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 295 ms 62500 KB Output is correct
17 Correct 51 ms 18772 KB Output is correct
18 Correct 74 ms 19996 KB Output is correct
19 Correct 354 ms 68296 KB Output is correct
20 Correct 209 ms 54096 KB Output is correct
21 Correct 31 ms 14676 KB Output is correct
22 Incorrect 240 ms 51504 KB Output isn't correct
23 Halted 0 ms 0 KB -