bzoj1624[usaco2008 Open] Clear and Present Danger Treasure Hunt Road
Test instructions
Find out the shortest length of the 1-a1-a2...-an-n walk by point. Points are less than or equal to 100.
Exercises
Floyd
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineMAXN 1105 #defineInc (I,J,K) for (int i=j;i<=k;i++)6 using namespacestd;7 8InlineintRead () {9 CharCh=getchar ();intf=1, x=0;Ten while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; Ch=GetChar ();} One while(ch>='0'&&ch<='9') x=x*Ten+ch-'0', ch=GetChar (); A returnf*x; - } - intmap[maxn][maxn],a[maxn* -],n,m,ans; the intMain () { -N=read (); M=read (); Inc (I,1, m) A[i]=read (); Inc (I,1, N) Inc (J,1, N) map[i][j]=read (); -Inc (K,1, N) Inc (I,1, N) Inc (J,1, N)if(Map[i][k]+map[k][j]<map[i][j]) map[i][j]=map[i][k]+Map[k][j]; -ans+=map[1][a[1]]; Inc (I,2, m) ans+=map[a[i-1]][a[i]]; Ans+=map[a[m]][n]; printf"%d", ans);return 0; +}
20160804
bzoj1624[usaco2008 Open] Clear and Present Danger Treasure Trail *