Submission #335760

# Submission time Handle Problem Language Result Execution time Memory
335760 2020-12-13T22:12:33 Z tevdore Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1159 ms 60080 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	priority_queue < pair < int, int > > pq;
	vector < pair < int, int > > v[N + 1];
	long long d[N + 1], f[N + 1];
	memset(d, 0, sizeof d);
	memset(f, 0, sizeof f);
	for(int i = 0; i < M; i++) {
		v[R[i][0]].push_back({R[i][1], L[i]});
		v[R[i][1]].push_back({R[i][0], L[i]});
	}
	for(int i = 0; i < K; i++) pq.push({0, P[i]}), f[P[i]] = 1; 
	while(pq.size()) {
		pair < int, int > p = pq.top();
		pq.pop();
		int dist = p.first;
		int u = p.second;
		if(!f[u]) {
			f[u] = 1;
			continue;
		}
		if(f[u] == 2) continue;
		if(f[u] == 1) f[u] = 2;
		d[u] = -dist;
		for(auto x : v[u]) pq.push({dist - x.second, x.first});
	}
    return d[0];
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 4 ms 748 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 7 ms 1132 KB Output is correct
13 Correct 6 ms 1132 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 4 ms 748 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 7 ms 1132 KB Output is correct
13 Correct 6 ms 1132 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 1035 ms 55496 KB Output is correct
17 Correct 99 ms 11244 KB Output is correct
18 Correct 132 ms 12920 KB Output is correct
19 Correct 1159 ms 60080 KB Output is correct
20 Correct 705 ms 50760 KB Output is correct
21 Correct 49 ms 4844 KB Output is correct
22 Correct 601 ms 31084 KB Output is correct