#include "crocodile.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;
typedef pair<int,int> pii;
const int maxn=1e5+10;
vector<pii> g[maxn];
pii cene[maxn];
void uradi(pii &a,int b){
if(b<a.xx){
a.yy=a.xx;
a.xx=b;
}else if(b<a.yy){
a.yy=b;
}
}
int kurc(int k,int* p){
priority_queue<pii,vector<pii>,greater<pii> > pq;
for(int i=0;i<maxn;i++) cene[i]={INT_MAX,INT_MAX};
for(int i=0;i<k;i++){
pq.push(mp(0,p[i]));
cene[p[i]]={0,0};
}
while(!pq.empty()){
pii vrh=pq.top();
pq.pop();
if(vrh.xx!=cene[vrh.yy].yy) continue;
if(vrh.yy==0) return vrh.xx;
for(pii i:g[vrh.yy]){
int sc=cene[i.xx].yy;
uradi(cene[i.xx],vrh.xx+i.yy);
if(sc>cene[i.xx].yy){
pq.push(mp(cene[i.xx].yy,i.xx));
}
}
}
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
for(int i=0;i<m;i++){
g[r[i][0]].pb(mp(r[i][1],l[i]));
g[r[i][1]].pb(mp(r[i][0],l[i]));
}
return kurc(k,p);
}
Compilation message
crocodile.cpp: In function 'int kurc(int, int*)':
crocodile.cpp:28:51: warning: control reaches end of non-void function [-Wreturn-type]
28 | priority_queue<pii,vector<pii>,greater<pii> > pq;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3404 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3404 KB |
Output is correct |
4 |
Correct |
3 ms |
3404 KB |
Output is correct |
5 |
Correct |
3 ms |
3404 KB |
Output is correct |
6 |
Correct |
3 ms |
3404 KB |
Output is correct |
7 |
Correct |
3 ms |
3404 KB |
Output is correct |
8 |
Correct |
3 ms |
3404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3404 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3404 KB |
Output is correct |
4 |
Correct |
3 ms |
3404 KB |
Output is correct |
5 |
Correct |
3 ms |
3404 KB |
Output is correct |
6 |
Correct |
3 ms |
3404 KB |
Output is correct |
7 |
Correct |
3 ms |
3404 KB |
Output is correct |
8 |
Correct |
3 ms |
3404 KB |
Output is correct |
9 |
Correct |
4 ms |
3660 KB |
Output is correct |
10 |
Correct |
2 ms |
3404 KB |
Output is correct |
11 |
Correct |
3 ms |
3532 KB |
Output is correct |
12 |
Correct |
6 ms |
3916 KB |
Output is correct |
13 |
Correct |
5 ms |
3944 KB |
Output is correct |
14 |
Correct |
3 ms |
3404 KB |
Output is correct |
15 |
Correct |
3 ms |
3532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3404 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3404 KB |
Output is correct |
4 |
Correct |
3 ms |
3404 KB |
Output is correct |
5 |
Correct |
3 ms |
3404 KB |
Output is correct |
6 |
Correct |
3 ms |
3404 KB |
Output is correct |
7 |
Correct |
3 ms |
3404 KB |
Output is correct |
8 |
Correct |
3 ms |
3404 KB |
Output is correct |
9 |
Correct |
4 ms |
3660 KB |
Output is correct |
10 |
Correct |
2 ms |
3404 KB |
Output is correct |
11 |
Correct |
3 ms |
3532 KB |
Output is correct |
12 |
Correct |
6 ms |
3916 KB |
Output is correct |
13 |
Correct |
5 ms |
3944 KB |
Output is correct |
14 |
Correct |
3 ms |
3404 KB |
Output is correct |
15 |
Correct |
3 ms |
3532 KB |
Output is correct |
16 |
Correct |
444 ms |
41972 KB |
Output is correct |
17 |
Correct |
83 ms |
10696 KB |
Output is correct |
18 |
Correct |
88 ms |
12020 KB |
Output is correct |
19 |
Correct |
538 ms |
45308 KB |
Output is correct |
20 |
Correct |
311 ms |
37540 KB |
Output is correct |
21 |
Correct |
41 ms |
6944 KB |
Output is correct |
22 |
Correct |
327 ms |
32564 KB |
Output is correct |