Submission #392751

# Submission time Handle Problem Language Result Execution time Memory
392751 2021-04-21T14:45:23 Z ritul_kr_singh Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
694 ms 77128 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include "crocodile.h"

const ll INF = 1e18;

struct twoSet{
	ll x = INF, y = INF; // x < y
	bool insert(ll v){
		if(v >= y) return false;
		y = v;
		if(x > y) swap(x, y);
		return true;
	}
	ll get(){ return y; }
};

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	vector<twoSet> dist(N);
	vector<pair<int, ll>> g[N];

	for(int i=0; i<M; ++i){
		g[R[i][0]].emplace_back(R[i][1], L[i]);
		g[R[i][1]].emplace_back(R[i][0], L[i]);
	}

	priority_queue<pair<ll, int>> q;

	bool vis[N]; fill(vis, vis + N, false);

	for(int i=0; i<K; ++i){
		q.emplace(0, P[i]);
		dist[P[i]].insert(0);
		dist[P[i]].insert(0);
	}

	while(!q.empty()){
		ll u = q.top().second, d = -q.top().first; q.pop();
		if(vis[u]) continue;
		vis[u] = true;
		for(auto &e : g[u]){
			ll v = e.first, w = e.second;
			if(dist[v].insert(d + w)) q.emplace(-dist[v].get(), v);
		}
	}
	return dist[0].get();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 4 ms 972 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 4 ms 972 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 527 ms 67464 KB Output is correct
17 Correct 106 ms 16660 KB Output is correct
18 Correct 165 ms 18936 KB Output is correct
19 Correct 694 ms 77128 KB Output is correct
20 Correct 322 ms 52372 KB Output is correct
21 Correct 47 ms 7284 KB Output is correct
22 Correct 392 ms 48752 KB Output is correct