Topic links
N Points M-road, each road has the right value, gives the starting point and the end point, to find a way to minimize the weight value. It is possible to ignore the weights of the K-route in the passing road.
Actually is Do Yivi, the specific look at the code
#include <bits/stdc++.h>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (I, A, n) for (int i = A; i<n; i++)#defineull unsigned long Longtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };Const intMAXN = 5e4+5;intdis[ A][60005],inch[ A][60005], num, head[maxn*2];intN, M, K, S, T;structedge{intto, Nextt, W;} E[MAXN*2];structnode{intu, x; Node () {} node (intUintx): U (U), x (x) {}};voidinit () {mem1 (head); Num=0;}voidAddintUintVintW) {e[num].to=v; E[num].nextt=Head[u]; E[NUM].W=W; Head[u]= num++;} Queue<node>Q;intDij () {mem2 (dis); Q.push (node (s),0)); dis[0][s] =0; inch[0][s] =1; while(!Q.empty ()) {Node TMP=Q.front (); Q.pop (); intU = tmp.u, x =tmp.x; inch[x] [U] =0; for(inti = Head[u]; ~i; i =e[i].nextt) { intv =e[i].to; if(dis[x][v]>dis[x][u]+E[I].W) {Dis[x][v]= dis[x][u]+E[I].W; if(!inch[X][v]) { inch[x] [V] =1; Q.push (Node (v, x)); } } } if(x<k) {x++; for(inti = Head[u]; ~i; i =e[i].nextt) { intv =e[i].to; if(dis[x][v]>dis[x-1][u]) {Dis[x][v]= dis[x-1][u]; if(!inch[X][v]) { inch[x] [V] =1; Q.push (Node (v, x)); } } } } } intAns =inf; for(inti =0; i<=k; i++) ans=min (ans, dis[i][t]); returnans;}intMain () {intx, y, Z; CIN>>n>>m>>k>>s>>T; Init (); while(m--) {scanf ("%d%d%d", &x, &y, &z); Add (x, y, z); Add (y, x, z); } intAns =Dij (); cout<<ans<<Endl; return 0;}
Bzoj 2763: [JLOI2011] Flight Route layering chart