#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
vector < pair < int , int > > ed[100005];
vector < int > wtex(100005,INT_MIN);
vector < bool > djikv(100005,0);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i=0;i<M;i++){
ed[R[i][0]].push_back(make_pair(R[i][1],L[i]));
ed[R[i][1]].push_back(make_pair(R[i][0],L[i]));
}
for(int i=0;i<K;i++){
wtex[P[i]]=0;
ed[100004].push_back(make_pair(P[i],0));
}
priority_queue < pair < int , int > > djikq;
djikq.push(make_pair(0,100004));
wtex[100004]=0;
while(!djikq.empty()){
int vn=djikq.top().second;
int wn=-djikq.top().first;
djikq.pop();
if(djikv[vn])continue;
//printf("vn=%d wn=%d wtex=%d\n",vn,wn,wtex[vn]);
if(wtex[vn]==INT_MIN){
wtex[vn]=-wn;
//printf(" vn=%d wn=%d wtex=%d\n",vn,wn,wtex[vn]);
continue;
}
if(wtex[vn]<0){
wtex[vn]=wn;
//printf(" vn=%d wn=%d wtex=%d\n",vn,wn,wtex[vn]);
}
djikv[vn]=1;
if(vn==0){
return wtex[vn];
}
for(int i=0;i<ed[vn].size();i++){
if(djikv[ed[vn][i].first]==0){
djikq.push(make_pair(-(wn+ed[vn][i].second),ed[vn][i].first));
}
}
}
return -1;
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<ed[vn].size();i++){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
122140 KB |
Output is correct |
2 |
Correct |
0 ms |
122140 KB |
Output is correct |
3 |
Correct |
3 ms |
122140 KB |
Output is correct |
4 |
Correct |
0 ms |
122272 KB |
Output is correct |
5 |
Correct |
3 ms |
122272 KB |
Output is correct |
6 |
Correct |
0 ms |
122140 KB |
Output is correct |
7 |
Correct |
0 ms |
122272 KB |
Output is correct |
8 |
Correct |
0 ms |
122272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
122428 KB |
Output is correct |
2 |
Correct |
0 ms |
122140 KB |
Output is correct |
3 |
Correct |
0 ms |
122272 KB |
Output is correct |
4 |
Correct |
3 ms |
122576 KB |
Output is correct |
5 |
Correct |
6 ms |
122672 KB |
Output is correct |
6 |
Correct |
0 ms |
122140 KB |
Output is correct |
7 |
Correct |
3 ms |
122272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
829 ms |
159576 KB |
Output is correct |
2 |
Correct |
116 ms |
126892 KB |
Output is correct |
3 |
Correct |
159 ms |
128080 KB |
Output is correct |
4 |
Correct |
693 ms |
161912 KB |
Output is correct |
5 |
Correct |
493 ms |
157420 KB |
Output is correct |
6 |
Correct |
43 ms |
124516 KB |
Output is correct |
7 |
Correct |
626 ms |
140900 KB |
Output is correct |