#include <bits/stdc++.h>
#include "crocodile.h"
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
//int N, M, K;
//int niz[1000005][2];
//int putd[1000005];
//int cham[100005];
vector<pii> v[100005];
pair<ll, ll> dist[100005];
set< pair<ll, int> > s;
int travel_plan(int n, int m, int e[][2], int l[], int k, int ex[]) {
for (int i = 0; i < m; i++) {
v[e[i][0]].push_back({e[i][1], l[i]});
v[e[i][1]].push_back({e[i][0], l[i]});
}
for (int i = 0; i < n; i++) {
dist[i] = {INF, INF};
s.insert({INF, i});
}
for (int i = 0; i < k; i++) {
s.erase({INF, ex[i]});
s.insert({0, ex[i]});
dist[ex[i]] = {0, 0};
}
while (!s.empty()) {
ll cost = (s.begin() -> first);
int cvor = (s.begin() -> second);
s.erase(s.begin());
for (int i = 0; i < v[cvor].size(); i++) {
ll novi = cost+v[cvor][i].Y;
int sus = v[cvor][i].X;
if (novi < dist[sus].X) {
s.erase({dist[sus].Y, sus});
dist[sus].Y = dist[sus].X;
dist[sus].X = novi;
s.insert({dist[sus].Y, sus});
}
else if (novi < dist[sus].Y) {
s.erase({dist[sus].Y, sus});
dist[sus].Y = novi;
s.insert({dist[sus].Y, sus});
}
}
}
return dist[0].Y;
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (int i = 0; i < v[cvor].size(); i++) {
| ~~^~~~~~~~~~~~~~~~
# |
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 |
3 ms |
2680 KB |
Output is correct |
4 |
Correct |
3 ms |
2824 KB |
Output is correct |
5 |
Correct |
3 ms |
2812 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
4 ms |
2772 KB |
Output is correct |
8 |
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 |
3 ms |
2680 KB |
Output is correct |
4 |
Correct |
3 ms |
2824 KB |
Output is correct |
5 |
Correct |
3 ms |
2812 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
4 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2900 KB |
Output is correct |
10 |
Correct |
2 ms |
2668 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
5 ms |
3156 KB |
Output is correct |
13 |
Correct |
4 ms |
3156 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 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 |
3 ms |
2680 KB |
Output is correct |
4 |
Correct |
3 ms |
2824 KB |
Output is correct |
5 |
Correct |
3 ms |
2812 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
4 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2900 KB |
Output is correct |
10 |
Correct |
2 ms |
2668 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
5 ms |
3156 KB |
Output is correct |
13 |
Correct |
4 ms |
3156 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2772 KB |
Output is correct |
16 |
Correct |
521 ms |
56484 KB |
Output is correct |
17 |
Correct |
139 ms |
20796 KB |
Output is correct |
18 |
Correct |
162 ms |
22248 KB |
Output is correct |
19 |
Correct |
821 ms |
63588 KB |
Output is correct |
20 |
Correct |
238 ms |
49660 KB |
Output is correct |
21 |
Correct |
69 ms |
9804 KB |
Output is correct |
22 |
Correct |
310 ms |
48152 KB |
Output is correct |