摘要:
还是prim预处理那些已经修好的路,变为0,即可。View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 103; 4 const int inf = 9999999; 5 struct node{ 6 int cost,is; 7 }mat[ maxn ][ maxn ]; 8 int dis[ maxn ],vis[ maxn ]; 9 int n,sum;10 11 int prim(){12 memset( vis,0,sizeof(vis));13 for( int i=1;. 阅读全文
posted @ 2013-01-30 22:23
xxx0624
阅读(329)
评论(0)
推荐(0)
摘要:
题意:给定n个坐标,求最小生成树。先将nike和apple之间的边加进来,并更新mat[nike][apple]=0,再贪心即可。或者:先把vis[ nike ]=vis[ apple ]=1,但是同时要更新dis[ i ]=min( mat[apple][i],mat[nike][i]);View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<algorithm> 5 using namespace std; 6 const int max 阅读全文
posted @ 2013-01-30 20:32
xxx0624
阅读(651)
评论(0)
推荐(0)
摘要:
预处理WA了N次。。。。。。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 const int maxn = 1000005; 6 const int maxm = 1005; 7 int s[ maxn ],vis[ maxm ]; 8 int main(){ 9 memset( s,0,sizeof(s) );10 memset( vis,0,sizeof(vis) );11 int cnt=0;12 i 阅读全文
posted @ 2013-01-30 18:13
xxx0624
阅读(410)
评论(0)
推荐(0)
摘要:
简单模拟View Code 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 int main(){ 5 int a[ 1001 ]; 6 int cnt; 7 int n; 8 while( scanf("%d",&n)!=EOF ){ 9 for( int i=0;i<n;i++ )10 scanf("%d",&a[ i ]);11 cnt=0;12 for( int i=0;i<n-1;i++ ){1... 阅读全文
posted @ 2013-01-30 16:56
xxx0624
阅读(195)
评论(0)
推荐(0)
摘要:
题意:从起点到终点,bfs不同的是对于图中的点,可能走多次,分别是在不同的时刻。myhash[ i ][ j ][ t%k ]=1:表示坐标( i,j )在 t%k 时刻走过,接下来再出现 t%k 就不用再走一次了。对于‘.’能入队,必须满足在该时刻没走过这个特点对于‘#’能入队,必须满足 该时刻没走过 且 该时刻 t%k==0 ;View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<stdlib.h> 5 #include<q 阅读全文
posted @ 2013-01-30 15:23
xxx0624
阅读(843)
评论(0)
推荐(0)

浙公网安备 33010602011771号