#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
typedef pair<int,int> pii;
typedef long long ll;
#define fi first
#define se second
namespace Wrap
{
Edgc
int g[SZ],cn[SZ];
}
int travel_plan(int N, int M_, int R[][2], int L[], int K, int P[])
{
using namespace Wrap;
for(int i=0;i<M_;++i)
adde(R[i][0],R[i][1],L[i]);
priority_queue<pii,vector<pii>,greater<pii> > pq;
for(int i=0;i<K;++i)
{
int x=P[i]; cn[x]=3;
for esb(x,e,b)
pq.push(pii(vc[e],b));
if(x==0) return 0;
}
while(!pq.empty())
{
pii x=pq.top(); pq.pop();
if(cn[x.se]>=2) continue;
++cn[x.se];
if(cn[x.se]<2) continue;
g[x.se]=x.fi;
if(x.se==0) return x.fi;
for esb(x.se,e,b)
pq.push(pii(x.fi+vc[e],b));
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
4 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
544 KB |
Output is correct |
12 |
Correct |
7 ms |
1300 KB |
Output is correct |
13 |
Correct |
4 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
4 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
544 KB |
Output is correct |
12 |
Correct |
7 ms |
1300 KB |
Output is correct |
13 |
Correct |
4 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
504 KB |
Output is correct |
16 |
Runtime error |
871 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
17 |
Halted |
0 ms |
0 KB |
- |