#include #define ft first #define sc second #define lb lower_bound #define ub upper_bound #define pb push_back #define pt(sth) cout << sth << "\n" #define chmax(a, b) {if(ab) a=b;} #define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD using namespace std; typedef long long ll; typedef pair P; static const ll INF=1e18; static const ll MAX=1e5+7; static const ll MOD=1e9+7; class Edge { public: ll t, w; Edge(ll t, ll w): t(t), w(w) {} }; ll N, M, L; vector g[2020]; void dijkstra(ll s, ll d[]) { ll i, u; ll clr[2020]; for(i=0; i q; q.push(P(0, s)); d[s]=0; while(q.size()) { P f=q.top(); q.pop(); u=f.sc; clr[u]=1; if(d[u]<-f.ft) continue; for(i=0; id[u]+e.w) { d[e.t]=d[u]+e.w; q.push(P(-d[e.t], e.t)); } } } } int main(void) { cin >> N >> M >> L; L--; ll c[2020]; ll i, j; for(i=0; i> c[i]; } for(i=0; i> a >> b >> c; a--; b--; g[a].pb(Edge(b, c)); g[b].pb(Edge(a, c)); } ll ans=INF; for(i=0; i0) f=0; } if(f) ans=0; } pt(ans); }