Submission #583551

# Submission time Handle Problem Language Result Execution time Memory
583551 2022-06-25T14:37:29 Z benson1029 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
451 ms 48564 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

vector< pair<int,int> > edg[100005];
long long dis[100005], dis1[100005], dis2[100005];
priority_queue< pair<long long, int> > pq;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for(int i=0; i<N; i++) {
		dis1[i] = dis2[i] = 1e17;
		dis[i] = 2e17;
	}
	for(int i=0; i<M; i++) {
		edg[R[i][0]].push_back({R[i][1], L[i]});
		edg[R[i][1]].push_back({R[i][0], L[i]});
	}
	for(int i=0; i<K; i++) {
		dis[P[i]] = dis1[P[i]] = dis2[P[i]] = 0;
		pq.push({0, P[i]});
	}
	while(!pq.empty()) {
		int curr = pq.top().second;
		if(dis[curr] != -pq.top().first) {
			pq.pop();
			continue;
		}
		if(curr==0) return dis[curr];
		pq.pop();
		for(auto i:edg[curr]) {
			if(dis[curr]+i.second < dis1[i.first]) {
				dis2[i.first] = dis1[i.first];
				dis1[i.first] = dis[curr]+i.second;
			} else if(dis[curr]+i.second < dis2[i.first]) {
				dis2[i.first] = dis[curr]+i.second;
			} else continue;
			if(dis2[i.first] < 1e17 && dis2[i.first] < dis[i.first]) {
				dis[i.first] = dis2[i.first];
				pq.push({-dis[i.first], i.first});
			}
		}
	}
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 4 ms 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 3 ms 2772 KB Output is correct
12 Correct 5 ms 2968 KB Output is correct
13 Correct 5 ms 3136 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 4 ms 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 3 ms 2772 KB Output is correct
12 Correct 5 ms 2968 KB Output is correct
13 Correct 5 ms 3136 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 389 ms 42784 KB Output is correct
17 Correct 88 ms 11936 KB Output is correct
18 Correct 81 ms 13312 KB Output is correct
19 Correct 451 ms 48564 KB Output is correct
20 Correct 273 ms 36552 KB Output is correct
21 Correct 35 ms 6628 KB Output is correct
22 Correct 280 ms 32264 KB Output is correct