Submission #62146

# Submission time Handle Problem Language Result Execution time Memory
62146 2018-07-27T13:52:53 Z aome Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
1018 ms 100468 KB
#include "crocodile.h"

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;

const int N = 100005;

int visit[N];
bool finish[N];
vector< pair<int, int> > G[N];

void add(int u, int v, int w) {
	G[u].push_back({w, v}), G[v].push_back({w, u});
}

int travel_plan(int n, int M, int R[][2], int L[], int K, int P[]) {
	priority_queue< ii, vector<ii>, greater<ii> > pq;
	for (int i = 0; i < M; ++i) {
		add(R[i][0], R[i][1], L[i]);
	}
	for (int i = 0; i < K; ++i) {
		pq.push({0, P[i]}), finish[P[i]] = 1;
	}
	while (pq.size()) {
		int u = pq.top().second; 
		int du = pq.top().first;
		pq.pop(), visit[u]++;
		if (finish[u]) {
			if (visit[u] != 1) continue;
		}
		else {
			if (visit[u] != 2) continue;
		}
		if (u == 0) return du;
		for (auto v : G[u]) pq.push({du + v.first, v.second});
	}
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2684 KB Output is correct
2 Correct 5 ms 2840 KB Output is correct
3 Correct 5 ms 2840 KB Output is correct
4 Correct 6 ms 2868 KB Output is correct
5 Correct 7 ms 2964 KB Output is correct
6 Correct 7 ms 2964 KB Output is correct
7 Correct 6 ms 3000 KB Output is correct
8 Correct 7 ms 3188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2684 KB Output is correct
2 Correct 5 ms 2840 KB Output is correct
3 Correct 5 ms 2840 KB Output is correct
4 Correct 6 ms 2868 KB Output is correct
5 Correct 7 ms 2964 KB Output is correct
6 Correct 7 ms 2964 KB Output is correct
7 Correct 6 ms 3000 KB Output is correct
8 Correct 7 ms 3188 KB Output is correct
9 Correct 8 ms 3360 KB Output is correct
10 Correct 5 ms 3360 KB Output is correct
11 Correct 8 ms 3360 KB Output is correct
12 Correct 12 ms 4000 KB Output is correct
13 Correct 11 ms 4000 KB Output is correct
14 Correct 6 ms 4000 KB Output is correct
15 Correct 6 ms 4000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2684 KB Output is correct
2 Correct 5 ms 2840 KB Output is correct
3 Correct 5 ms 2840 KB Output is correct
4 Correct 6 ms 2868 KB Output is correct
5 Correct 7 ms 2964 KB Output is correct
6 Correct 7 ms 2964 KB Output is correct
7 Correct 6 ms 3000 KB Output is correct
8 Correct 7 ms 3188 KB Output is correct
9 Correct 8 ms 3360 KB Output is correct
10 Correct 5 ms 3360 KB Output is correct
11 Correct 8 ms 3360 KB Output is correct
12 Correct 12 ms 4000 KB Output is correct
13 Correct 11 ms 4000 KB Output is correct
14 Correct 6 ms 4000 KB Output is correct
15 Correct 6 ms 4000 KB Output is correct
16 Correct 950 ms 73032 KB Output is correct
17 Correct 136 ms 73032 KB Output is correct
18 Correct 169 ms 73032 KB Output is correct
19 Correct 1018 ms 90548 KB Output is correct
20 Correct 475 ms 90548 KB Output is correct
21 Correct 71 ms 90548 KB Output is correct
22 Correct 940 ms 100468 KB Output is correct