Submission #519950

# Submission time Handle Problem Language Result Execution time Memory
519950 2022-01-27T22:09:24 Z sliviu Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
461 ms 71084 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pi = pair<int, int>;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
	vector<vector<pair<int, int>>> G(n);
	vector<int> seen(n);
	for (int i = 0;i < m;++i) {
		int x, y;
		G[r[i][0]].emplace_back(r[i][1], l[i]);
		G[r[i][1]].emplace_back(r[i][0], l[i]);
	}
	auto comp = [&](pi a, pi b) {
		return a.second > b.second;
	};
	priority_queue<pi, vector<pi>, decltype(comp)> PQ(comp);
	for (int i = 0;i < k;++i) {
		PQ.emplace(p[i], 0);
		++seen[p[i]];
	}
	while (!PQ.empty()) {
		int node, cost;
		tie(node, cost) = PQ.top();
		PQ.pop();
		if (++seen[node] == 2) {
			if (node == 0)
				return cost;
			for (auto x : G[node])
				PQ.emplace(x.first, x.second + cost);
		}
	}
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:11:7: warning: unused variable 'x' [-Wunused-variable]
   11 |   int x, y;
      |       ^
crocodile.cpp:11:10: warning: unused variable 'y' [-Wunused-variable]
   11 |   int x, y;
      |          ^
crocodile.cpp:8:36: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  vector<vector<pair<int, int>>> G(n);
      |                                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 5 ms 1100 KB Output is correct
13 Correct 3 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 5 ms 1100 KB Output is correct
13 Correct 3 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 449 ms 71084 KB Output is correct
17 Correct 81 ms 13340 KB Output is correct
18 Correct 89 ms 14756 KB Output is correct
19 Correct 461 ms 66836 KB Output is correct
20 Correct 266 ms 55224 KB Output is correct
21 Correct 39 ms 5916 KB Output is correct
22 Correct 452 ms 44740 KB Output is correct