Submission #964055

# Submission time Handle Problem Language Result Execution time Memory
964055 2024-04-16T09:03:01 Z pragmatist Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
593 ms 49104 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = (int)1e5+7;
const long long INF = (long long)1e18+7;
 
vector<pair<int, int> > g[N];
int n, m;
long long d1[N], d2[N];
 
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 u = _R[i][0], v = _R[i][1], w = _L[i];
		u++;
		v++;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	for(int i = 1; i <= n; ++i) {
		d1[i] = d2[i] = INF;
	}

	set<pair<long long, int> > q;
	for(int i = 0; i < _K; ++i) {
		int v = _P[i]+1;
		d1[v]=d2[v]=0;
		q.insert({0, v});
	}
	while(!q.empty()) {
		int v = q.begin()->second;
	    q.erase(q.begin());

		for(auto [to, w] : g[v]) {
			if(d2[v]+w<d1[to]) {
			    q.erase({d2[to], to});
				d2[to]=d1[to];
				d1[to]=d2[v]+w;
				q.insert({d2[to], to});				
			} else {    
				if(d2[v]+w<d2[to]) {
				    q.erase({d2[to], to});
					d2[to]=d2[v]+w;
					q.insert({d2[to], to});				
				}
			}
		}
	}
	return d2[1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 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 6576 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 6492 KB Output is correct
3 Correct 2 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 6576 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 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 4 ms 8796 KB Output is correct
13 Correct 3 ms 8792 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 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 6492 KB Output is correct
3 Correct 2 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 6576 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 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 4 ms 8796 KB Output is correct
13 Correct 3 ms 8792 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 405 ms 44228 KB Output is correct
17 Correct 56 ms 15548 KB Output is correct
18 Correct 97 ms 16988 KB Output is correct
19 Correct 593 ms 49104 KB Output is correct
20 Correct 206 ms 41044 KB Output is correct
21 Correct 33 ms 13012 KB Output is correct
22 Correct 231 ms 37200 KB Output is correct