#include <bits/stdc++.h>
#define MAX_V 0x7f7f7f
#define inf 100100
using namespace std;
struct{
int from;
int to;
int cost;
}es[MAX_V];
int n,m,s,d[214748364];
void spfa(int s){
for(int i=1;i<=n;i++) d[i]=inf;
d[s]=0;
while(1){
bool flag=0;
for(int i=1;i<=m;i++){
if(d[es[i].from]+es[i].cost<d[es[i].to]){
flag=1;
d[es[i].to]=d[es[i].from]+es[i].cost;
}
}
if(flag==0) break;
}
return;
}
int main(){
cin>>n>>m>>s;
for(int i=1;i<=m;i++){
cin>>es[i].from>>es[i].to>>es[i].cost;
}
spfa(s);
for(int i=1;i<=n;i++){
if(d[i]<inf) cout<<d[i]<<" ";
else cout<<"2147483647"<<" ";
}
return 0;
}
足够优秀的写法不要想些其他什么vector啊,能用结构体多好