#include<bits/stdc++.h>
#define int long long
using namespace std;
const int M=1000001,N=1001;
int n,m,k,head[N],head2[N],cnt,cnt2,dis[N],u,v,w;
bool vis[N];
struct nod{
int next,to,dis;
}e[M],e2[M];
struct node{
int pos,dis;
};
bool operator < (node a,node b){
return a.dis+dis[a.pos]>b.dis+dis[b.pos];
}
void add(int u,int v,int w){
cnt++;
e[cnt].next=head[u];
e[cnt].to=v;
e[cnt].dis=w;
head[u]=cnt;
}
void add2(int u,int v,int w){
cnt2++;
e2[cnt].next=head[u];
e2[cnt].to=v;
e2[cnt].dis=w;
head2[u]=cnt2;
}
void SPFA(){
queue<int>d;
d.push(1);
memset(dis,0x3f,sizeof dis);
memset(vis,0,sizeof vis);
dis[1]=0;
while(d.size()){
int u=d.front();
d.pop();
vis[u]=1;
for(int i=head[u];i;i=e[i].next){
int to=e[i].to;
if(dis[to]>dis[u]+e[i].dis){
dis[to]=dis[u]+e[i].dis;
if(!vis[to]) d.push(to);
}
}
}
}
int A_star(int &k){
priority_queue<node>d;
d.push({n,0});
while(d.size()){
node now=d.top();
d.pop();
if(now.pos==1){
cout<<now.dis<<endl;
k--;
if(!k) return 0;
}
int u=now.pos;
for(int i=head2[u];i;i=e2[i].next){
int to=e2[i].to;
d.push({to,now.dis+e2[i].dis});
}
}
return k;
}
signed main(){
cin>>n>>m>>k;
for(int i=1;i<=m;i++){
cin>>u>>v>>w;
add(v,u,w);
add2(u,v,w);
}
SPFA();
A_star(k);
while(k--) cout<<-1<<endl;
}
两个关注
精神状态不太好,傻逼错误倾盆