Original title Address
Quite simple a problem, the result because a moment silly to write wrong a small place, cause wa become a dog _ (: З"∠) _
Code:
1#include <iostream>2#include <cstring>3#include <queue>4 5 using namespacestd;6 7 #defineMax_v 100088 #defineMax_e 2000089 Ten intN, M, K, T; One intF[max_v]; A BOOLV[max_v]; - intN[max_e]; - intW[max_e]; the intT[max_e]; - intMax_w =1;; - intMin_w =1000000; - + BOOLCheckintl) { -queue<pair<int,int> >Q; +memset (V,0,sizeof(v)); AQ.push (pair<int,int> (1, K)); at while(!Q.empty ()) { -pair<int,int> P =Q.front (); - Q.pop (); - if(P.first = = T && p.second >=0) - return true; - if(P.second = =0||V[p.first]) in Continue; -V[p.first] =true; to for(inti = F[p.first]; I! =0; i =N[i]) { + if(W[i] > L | |V[t[i]]) - Continue; theQ.push (pair<int,int> (T[i], P.second-1)); * } $ }Panax Notoginseng return false; - } the + intFindintLintr) { A intres =R; the while(L <=r) { + intm = (L + r)/2; - if(check (m)) { $res =m; $r = M-1; - } - Else theL = m +1; - }Wuyi returnRes; the } - Wu intMain () { -memset (N,0,sizeof(n)); Aboutscanf"%d%d%d%d", &n, &m, &k, &T); $ for(inti =0, j =0; i < M; i++) { - intA, B, C; -scanf"%d%d%d", &a, &b, &c); -Min_w =min (Min_w, c); AMax_w =Max (Max_w, c); +J + +; theW[J] =C; -T[J] =b; $N[J] =F[a]; theF[a] =J; theJ + +; theW[J] =C; theT[J] =A; -N[J] =F[b]; inF[B] =J; the } the if(T = =1) Aboutprintf"0\n"); the Else theprintf"%d\n", find (Min_w, max_w)); the return 0; +}
hihocoder#1139 Two-point two answer