#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=1e5+5;
const ll inf=2e9;
struct duongdi
{
int u;
ll w;
bool operator < (const duongdi &o)const
{
return w>o.w;
}
};
pii d[maxN+1];
vector<duongdi> adj[maxN+1];
priority_queue<duongdi> pq;
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[])
{
for(int i=0;i<M;i++)
{
adj[R[i][0]].push_back({R[i][1],L[i]});
adj[R[i][1]].push_back({R[i][0],L[i]});
}
for(int i=0;i<N;i++)
{
d[i]={INT_MAX,INT_MAX};
}
for(int i=0;i<K;i++)
{
pq.push({P[i],0});
d[P[i]]={0,0};
}
while(!pq.empty())
{
duongdi tmp=pq.top();
pq.pop();
int u=tmp.u;
ll w=tmp.w;
//cout<<u<<" "<<w<<'\n';
if(d[u].fi<w)
{
continue;
}
for(auto i:adj[u])
{
int v=i.u;
//cout<<1<<" "<<v<<" ";
if(d[v].fi>d[u].fi+i.w)
{
d[v].fi=d[u].fi+i.w;
if(d[v].se>d[u].fi+i.w)
{
swap(d[v].se,d[v].fi);
}
if(d[v].fi<INT_MAX)
{
pq.push({v,d[v].fi});
}
}
//cout<<d[v].fi<<'\n';
}
}
return d[0].fi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
7280 KB |
Output is correct |
14 |
Correct |
1 ms |
6748 KB |
Output is correct |
15 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
1 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
7280 KB |
Output is correct |
14 |
Correct |
1 ms |
6748 KB |
Output is correct |
15 |
Correct |
1 ms |
6748 KB |
Output is correct |
16 |
Correct |
205 ms |
70856 KB |
Output is correct |
17 |
Correct |
34 ms |
16500 KB |
Output is correct |
18 |
Correct |
42 ms |
18776 KB |
Output is correct |
19 |
Correct |
240 ms |
75972 KB |
Output is correct |
20 |
Correct |
142 ms |
59512 KB |
Output is correct |
21 |
Correct |
18 ms |
10844 KB |
Output is correct |
22 |
Incorrect |
153 ms |
55148 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |