Submission #921475

# Submission time Handle Problem Language Result Execution time Memory
921475 2024-02-04T00:01:41 Z Lobo Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
500 ms 90880 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define int long long
const int maxn = 1e5+10;
const int inf = 1e18+10;
 
 
int32_t travel_plan(int32_t n, int32_t m, int32_t R[][2], int32_t L[], int32_t k, int32_t P[])
{
	vector<vector<pair<int,int>>> g(n);
	for(int i = 0; i < m; i++) {
		g[R[i][0]].pb(mp(R[i][1],L[i]));
		g[R[i][1]].pb(mp(R[i][0],L[i]));
	}
 
	vector<int> d1(n),d2(n);
	for(int i = 0; i < n; i++) {
		d1[i] = d2[i] = inf;
	}
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	for(int i = 0; i < k; i++) {
		int v = P[i];
		d1[v] = d2[v] = 0;
		pq.push(mp(0,v));
	}
 	
 	vector<int> mark(n,0);
	while(pq.size()) {
		int u = pq.top().sc;
		int dis2 = pq.top().fr;
		pq.pop();
      	if(mark[u]) continue;
		mark[u] = 1;
 
		for(auto V : g[u]) {
			int v = V.fr;
			int w = V.sc;
			if(d2[v] > d2[u]+w) {
				d2[v] = d2[u]+w;
				if(d2[v] < d1[v]) swap(d2[v],d1[v]);
				if(d2[v] != inf) pq.push(mp(d2[v],v));
			}
		}
	}
 
	return (int32_t) d2[0];
}
 
 

Compilation message

crocodile.cpp: In function 'int32_t travel_plan(int32_t, int32_t, int32_t (*)[2], int32_t*, int32_t, int32_t*)':
crocodile.cpp:35:7: warning: unused variable 'dis2' [-Wunused-variable]
   35 |   int dis2 = pq.top().fr;
      |       ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4804 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4696 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 4 ms 5212 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4804 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4696 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 4 ms 5212 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 340 ms 82476 KB Output is correct
17 Correct 56 ms 20080 KB Output is correct
18 Correct 82 ms 22608 KB Output is correct
19 Correct 500 ms 90880 KB Output is correct
20 Correct 225 ms 66232 KB Output is correct
21 Correct 28 ms 11356 KB Output is correct
22 Correct 250 ms 64592 KB Output is correct