#include "crocodile.h"
#include <vector>
#include <queue>
#define ad push_back
#define lli long long
#define MP make_pair
#define fr first
#define sc second
using namespace std;
const int N = 1e6 + 30;
vector<pair<int, lli> > g[N];
int n;
lli col[N];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n = N;
for (int i = 0; i < M; i++)
{
g[R[i][0]].ad(MP(R[i][1], L[i]));
g[R[i][1]].ad(MP(R[i][0], L[i]));
}
for (int i = 0; i < n; i++) col[i] = -2;
priority_queue <pair<lli, int> > q;
for (int i = 0; i < K; i++)
{
col[P[i]] = -1;
q.push(MP(0, P[i]));
}
while (!q.empty())
{
auto p = q.top();
q.pop();
if (col[p.sc] == -2)
{
col[p.sc] = -1;
}
else if (col[p.sc] == -1)
{
col[p.sc] = -p.fr;
for (auto& p1 : g[p.sc])
{
if (col[p1.fr] >= 0) continue;
q.push(MP(p.fr - p1.sc, p1.fr));
}
}
}
return col[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Correct |
14 ms |
23756 KB |
Output is correct |
3 |
Correct |
14 ms |
23756 KB |
Output is correct |
4 |
Correct |
14 ms |
23884 KB |
Output is correct |
5 |
Correct |
14 ms |
23920 KB |
Output is correct |
6 |
Correct |
14 ms |
23800 KB |
Output is correct |
7 |
Correct |
14 ms |
23920 KB |
Output is correct |
8 |
Correct |
14 ms |
23884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Correct |
14 ms |
23756 KB |
Output is correct |
3 |
Correct |
14 ms |
23756 KB |
Output is correct |
4 |
Correct |
14 ms |
23884 KB |
Output is correct |
5 |
Correct |
14 ms |
23920 KB |
Output is correct |
6 |
Correct |
14 ms |
23800 KB |
Output is correct |
7 |
Correct |
14 ms |
23920 KB |
Output is correct |
8 |
Correct |
14 ms |
23884 KB |
Output is correct |
9 |
Correct |
16 ms |
24360 KB |
Output is correct |
10 |
Correct |
13 ms |
23760 KB |
Output is correct |
11 |
Correct |
15 ms |
24004 KB |
Output is correct |
12 |
Correct |
19 ms |
24948 KB |
Output is correct |
13 |
Correct |
19 ms |
24908 KB |
Output is correct |
14 |
Correct |
15 ms |
23840 KB |
Output is correct |
15 |
Correct |
14 ms |
23908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Correct |
14 ms |
23756 KB |
Output is correct |
3 |
Correct |
14 ms |
23756 KB |
Output is correct |
4 |
Correct |
14 ms |
23884 KB |
Output is correct |
5 |
Correct |
14 ms |
23920 KB |
Output is correct |
6 |
Correct |
14 ms |
23800 KB |
Output is correct |
7 |
Correct |
14 ms |
23920 KB |
Output is correct |
8 |
Correct |
14 ms |
23884 KB |
Output is correct |
9 |
Correct |
16 ms |
24360 KB |
Output is correct |
10 |
Correct |
13 ms |
23760 KB |
Output is correct |
11 |
Correct |
15 ms |
24004 KB |
Output is correct |
12 |
Correct |
19 ms |
24948 KB |
Output is correct |
13 |
Correct |
19 ms |
24908 KB |
Output is correct |
14 |
Correct |
15 ms |
23840 KB |
Output is correct |
15 |
Correct |
14 ms |
23908 KB |
Output is correct |
16 |
Correct |
785 ms |
118116 KB |
Output is correct |
17 |
Correct |
100 ms |
37948 KB |
Output is correct |
18 |
Correct |
128 ms |
40428 KB |
Output is correct |
19 |
Correct |
952 ms |
121876 KB |
Output is correct |
20 |
Correct |
592 ms |
105532 KB |
Output is correct |
21 |
Correct |
60 ms |
30532 KB |
Output is correct |
22 |
Correct |
493 ms |
85480 KB |
Output is correct |