#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=2e5+5;
vector<pair<int,int>>v[N];
int dist[N];
int tmp[N];
int par[N];
vector<pair<int,int>>vc;
signed main(){
int n,m,s,t,x,y;
cin>>n>>m>>s>>t>>x>>y;
for(int i=0;i<m;i++){
int a,b,c;
cin>>a>>b>>c;
v[a].pb({b,c});
v[b].pb({a,c});
}
for(int i=1;i<=n;i++){
dist[i]=1e9;
}
priority_queue<pair<int,int>>q;
q.push({0,s});
par[s]=s;
dist[s]=0;
while(!q.empty()){
int w=-q.top().ff;
int a=q.top().ss;
q.pop();
if(dist[a]<w)continue;
for(auto p:v[a]){
int b=p.ff;
int c=p.ss;
if(dist[a]+c<dist[b]){
dist[b]=dist[a]+c;
par[b]=a;
q.push({-dist[b],b});
}
}
}
while(t!=s){
v[t].pb({par[t],0});
v[par[t]].pb({t,0});
t=par[t];
}
for(int i=1;i<=n;i++){
dist[i]=1e9;
}
s=x;
q.push({0,s});
par[s]=s;
dist[s]=0;
while(!q.empty()){
int w=-q.top().ff;
int a=q.top().ss;
q.pop();
if(dist[a]<w)continue;
for(auto p:v[a]){
int b=p.ff;
int c=p.ss;
if(dist[a]+c<dist[b]){
dist[b]=dist[a]+c;
par[b]=a;
q.push({-dist[b],b});
}
}
}
cout<<dist[y];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
22216 KB |
Output is correct |
2 |
Correct |
217 ms |
21204 KB |
Output is correct |
3 |
Correct |
251 ms |
25796 KB |
Output is correct |
4 |
Incorrect |
211 ms |
21196 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
23748 KB |
Output is correct |
2 |
Correct |
229 ms |
24048 KB |
Output is correct |
3 |
Correct |
253 ms |
26624 KB |
Output is correct |
4 |
Correct |
226 ms |
27000 KB |
Output is correct |
5 |
Correct |
233 ms |
27860 KB |
Output is correct |
6 |
Correct |
245 ms |
29124 KB |
Output is correct |
7 |
Correct |
236 ms |
31792 KB |
Output is correct |
8 |
Correct |
222 ms |
27580 KB |
Output is correct |
9 |
Correct |
230 ms |
27852 KB |
Output is correct |
10 |
Correct |
229 ms |
27320 KB |
Output is correct |
11 |
Runtime error |
288 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
8820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
22216 KB |
Output is correct |
2 |
Correct |
217 ms |
21204 KB |
Output is correct |
3 |
Correct |
251 ms |
25796 KB |
Output is correct |
4 |
Incorrect |
211 ms |
21196 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |