#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,m,k,d[100005],dd[100005];
vector<P>g[100005];
int travel_plan(int N, int M, int R[][2], int L[], int K, int T[]){
n=N,m=M,k=K;
for(int i=0;i<m;i++){
ll a=R[i][0],b=R[i][1],c=L[i];
g[a].PB(P(b,c));
g[b].PB(P(a,c));
}
for(int i=0;i<n;i++)d[i]=INF,dd[i]=INF;
priority_queue<P,vector<P>,greater<P> >dik;
for(int i=0;i<k;i++){
ll v=T[i];
d[v]=0;
dd[v]=0;
dik.push(P(0,v));
}
while(!dik.empty()){
ll c=dik.top().F,v=dik.top().S;
dik.pop();
if(dd[v]<c)continue;
for(int i=0;i<g[v].size();i++){
ll u=g[v][i].F,p=c+g[v][i].S;
if(d[u]>p)swap(d[u],p);
if(dd[u]>p){
dd[u]=p;
dik.push(P(p,u));
}
}
}
return dd[0];
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[v].size();i++){
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
5 ms |
2816 KB |
Output is correct |
7 |
Correct |
4 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
5 ms |
2816 KB |
Output is correct |
7 |
Correct |
4 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
9 |
Correct |
7 ms |
3328 KB |
Output is correct |
10 |
Correct |
4 ms |
2688 KB |
Output is correct |
11 |
Correct |
5 ms |
2816 KB |
Output is correct |
12 |
Correct |
8 ms |
3320 KB |
Output is correct |
13 |
Correct |
7 ms |
3456 KB |
Output is correct |
14 |
Correct |
4 ms |
2688 KB |
Output is correct |
15 |
Correct |
5 ms |
2816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
5 ms |
2816 KB |
Output is correct |
7 |
Correct |
4 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
9 |
Correct |
7 ms |
3328 KB |
Output is correct |
10 |
Correct |
4 ms |
2688 KB |
Output is correct |
11 |
Correct |
5 ms |
2816 KB |
Output is correct |
12 |
Correct |
8 ms |
3320 KB |
Output is correct |
13 |
Correct |
7 ms |
3456 KB |
Output is correct |
14 |
Correct |
4 ms |
2688 KB |
Output is correct |
15 |
Correct |
5 ms |
2816 KB |
Output is correct |
16 |
Correct |
702 ms |
82864 KB |
Output is correct |
17 |
Correct |
86 ms |
17696 KB |
Output is correct |
18 |
Correct |
124 ms |
20256 KB |
Output is correct |
19 |
Correct |
822 ms |
89280 KB |
Output is correct |
20 |
Correct |
387 ms |
67732 KB |
Output is correct |
21 |
Correct |
45 ms |
9848 KB |
Output is correct |
22 |
Correct |
344 ms |
64460 KB |
Output is correct |