Submission #153348

# Submission time Handle Problem Language Result Execution time Memory
153348 2019-09-13T15:14:24 Z junodeveloper Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
809 ms 90136 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll INF=1e18;
int n,m;
ll D[100010],E[100010][2];
vector<pll> adj[100010];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	int i;
	for(i=0;i<M;i++) {
		int u=R[i][0],v=R[i][1];
		adj[u].push_back({v,L[i]});
		adj[v].push_back({u,L[i]});
	}
	priority_queue<pll,vector<pll>,greater<pll> > pq;
	for(i=0;i<N;i++) { 
		D[i]=INF;
		E[i][0]=E[i][1]=-1;
	}
	for(i=0;i<K;i++) {
		D[P[i]]=0;
		pq.push({D[P[i]],P[i]});
	}
	while(!pq.empty()) {
		ll w,u; tie(w,u)=pq.top(); pq.pop();
		if(D[u]<w) continue;
		for(auto& it:adj[u]) {
			ll v,c; tie(v,c)=it;
			ll d=w+c;
			if(E[v][0]==-1) E[v][0]=d;
			else if(d<E[v][0]) E[v][1]=E[v][0],E[v][0]=d;
			else if(E[v][1]==-1) E[v][1]=d;
			else if(d<E[v][1]) E[v][1]=d;
			if(E[v][1]!=-1) {
				if(E[v][1]<D[v]) {
					D[v]=E[v][1];
					pq.push({D[v],v});
				}
			}
		}
	}
	return D[0];
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2808 KB Output is correct
4 Correct 5 ms 2808 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 6 ms 2808 KB Output is correct
7 Correct 6 ms 2852 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2808 KB Output is correct
4 Correct 5 ms 2808 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 6 ms 2808 KB Output is correct
7 Correct 6 ms 2852 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 7 ms 3064 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2812 KB Output is correct
12 Correct 8 ms 3324 KB Output is correct
13 Correct 8 ms 3420 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 5 ms 2808 KB Output is correct
4 Correct 5 ms 2808 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 6 ms 2808 KB Output is correct
7 Correct 6 ms 2852 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 7 ms 3064 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2812 KB Output is correct
12 Correct 8 ms 3324 KB Output is correct
13 Correct 8 ms 3420 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2812 KB Output is correct
16 Correct 692 ms 83020 KB Output is correct
17 Correct 104 ms 18396 KB Output is correct
18 Correct 142 ms 20856 KB Output is correct
19 Correct 809 ms 90136 KB Output is correct
20 Correct 393 ms 67528 KB Output is correct
21 Correct 53 ms 10104 KB Output is correct
22 Correct 419 ms 64380 KB Output is correct