Submission #392746

# Submission time Handle Problem Language Result Execution time Memory
392746 2021-04-21T14:37:35 Z ritul_kr_singh Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
676 ms 77004 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;

	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(d != dist[u].get()) continue;
		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 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 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 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 4 ms 972 KB Output is correct
13 Correct 4 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 416 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 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 4 ms 972 KB Output is correct
13 Correct 4 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 416 KB Output is correct
16 Correct 529 ms 67560 KB Output is correct
17 Correct 105 ms 16572 KB Output is correct
18 Correct 134 ms 18756 KB Output is correct
19 Correct 676 ms 77004 KB Output is correct
20 Correct 320 ms 52496 KB Output is correct
21 Correct 47 ms 7312 KB Output is correct
22 Incorrect 367 ms 48816 KB Output isn't correct