Submission #600297

# Submission time Handle Problem Language Result Execution time Memory
600297 2022-07-20T17:01:43 Z shezitt Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
468 ms 75140 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << x << endl;
#define raya cout << "===========================" << endl;
typedef long long ll;

using namespace std;

const ll INF = 1e18;
const int N = 1e5+5;
int n, m;

int vis[N];
vector<pair<int,int>> g[N];

int travel_plan(int nn, int mm, int R[][2], int L[], int K, int P[]){
	n = nn;
	m = mm;
	for(int i=0; i<m; ++i){
		g[R[i][0]].push_back({R[i][1], L[i]});
		g[R[i][1]].push_back({R[i][0], L[i]});
	}
	
	priority_queue<pair<ll,int>> pq;
	for(int i=0; i<K; ++i){
		pq.push({0, P[i]});
		vis[P[i]] = 1;
	}
	while(!pq.empty()){
		auto w = -pq.top().first; auto u = pq.top().second;
		pq.pop();
		if(!vis[u]){
			vis[u] = 1;
			continue;
		}
		if(vis[u] == 2){
			continue;
		}
		if(u == 0){
			return w;
		}
		vis[u] = 2;
		for(auto v : g[u]){
			if(vis[v.first] == 2){
				continue;
			}
			pq.push({-(w+v.second), v.first});
		}
		
	}
	assert(0);
	return -1;
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2740 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 2672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2740 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 2672 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2664 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 7 ms 3440 KB Output is correct
13 Correct 4 ms 3540 KB Output is correct
14 Correct 2 ms 2720 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2740 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 2672 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2664 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 7 ms 3440 KB Output is correct
13 Correct 4 ms 3540 KB Output is correct
14 Correct 2 ms 2720 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
16 Correct 417 ms 72508 KB Output is correct
17 Correct 68 ms 13360 KB Output is correct
18 Correct 75 ms 14752 KB Output is correct
19 Correct 468 ms 75140 KB Output is correct
20 Correct 309 ms 66096 KB Output is correct
21 Correct 34 ms 7532 KB Output is correct
22 Correct 374 ms 46292 KB Output is correct