#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define int long long
int n, m;
const int MXN = 100005;
vector<pair<int, int> > adj[MXN];
int vis[MXN];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n = N, m = M;
for (int i=0; i<m; i++) {
int a, b, w;
a = R[i][0], b = R[i][1], w = L[i];
adj[a].push_back(make_pair(b, w));
adj[b].push_back(make_pair(a, w));
}
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > proc;
for (int i=0; i<K; i++) {
int x = P[i];
proc.push(make_pair(0, x));
vis[x] = 1;
}
while (!proc.empty()) {
int no = proc.top().second;
int di = proc.top().first;
proc.pop();
if (vis[no] == 0) {
vis[no]++;
continue;
}
if (vis[no] == 2) {
continue;
}
if (no == 0) {
return di;
}
vis[no] = 2;
for (int i=0; i<adj[no].size(); i++) {
int ot = adj[no][i].first;
int od = adj[no][i].second + di;
if (vis[ot] == 2) continue;
proc.push(make_pair(od, ot));
}
}
assert(false);
return -1;
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:47:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<adj[no].size(); i++) {
~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2816 KB |
Output is correct |
5 |
Correct |
7 ms |
2816 KB |
Output is correct |
6 |
Correct |
6 ms |
2688 KB |
Output is correct |
7 |
Correct |
7 ms |
2816 KB |
Output is correct |
8 |
Correct |
7 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2816 KB |
Output is correct |
5 |
Correct |
7 ms |
2816 KB |
Output is correct |
6 |
Correct |
6 ms |
2688 KB |
Output is correct |
7 |
Correct |
7 ms |
2816 KB |
Output is correct |
8 |
Correct |
7 ms |
2688 KB |
Output is correct |
9 |
Correct |
7 ms |
2944 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
11 |
Correct |
7 ms |
2816 KB |
Output is correct |
12 |
Correct |
10 ms |
3200 KB |
Output is correct |
13 |
Correct |
9 ms |
3072 KB |
Output is correct |
14 |
Correct |
7 ms |
2688 KB |
Output is correct |
15 |
Correct |
8 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2816 KB |
Output is correct |
5 |
Correct |
7 ms |
2816 KB |
Output is correct |
6 |
Correct |
6 ms |
2688 KB |
Output is correct |
7 |
Correct |
7 ms |
2816 KB |
Output is correct |
8 |
Correct |
7 ms |
2688 KB |
Output is correct |
9 |
Correct |
7 ms |
2944 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
11 |
Correct |
7 ms |
2816 KB |
Output is correct |
12 |
Correct |
10 ms |
3200 KB |
Output is correct |
13 |
Correct |
9 ms |
3072 KB |
Output is correct |
14 |
Correct |
7 ms |
2688 KB |
Output is correct |
15 |
Correct |
8 ms |
2816 KB |
Output is correct |
16 |
Correct |
546 ms |
48100 KB |
Output is correct |
17 |
Correct |
94 ms |
10104 KB |
Output is correct |
18 |
Correct |
109 ms |
11384 KB |
Output is correct |
19 |
Correct |
589 ms |
50656 KB |
Output is correct |
20 |
Correct |
330 ms |
36588 KB |
Output is correct |
21 |
Correct |
50 ms |
7544 KB |
Output is correct |
22 |
Correct |
483 ms |
46332 KB |
Output is correct |