2011年4月30日

More is better

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>#define maxn 10000010 int father[maxn],d[maxn];int find(int x){ return x==father[x]?x:father[x]=find(father[x]);}void merge(int x,int y){ x=find(x),y=find(y); if(x!=y) father[x]=y; }int main( ){ int N,i,j,a,b,k,t=0; while(scanf(& 阅读全文

posted @ 2011-04-30 23:51 more think, more gains 阅读(176) 评论(0) 推荐(0) 编辑

how many tables

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int father[1100];int find(int x){ return x==father[x]?x:father[x]=find(father[x]);}void merge(int x,int y){ x=find(x),y=find(y); if(x!=y) father[x]... 阅读全文

posted @ 2011-04-30 22:26 more think, more gains 阅读(141) 评论(0) 推荐(0) 编辑

最短路径问题

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int N,M;int map[1100][1100],dis[1100],visit[1100],exp[1100][1100],price[1100];const int inf=0x7fffffff;int dij(int x,int y){ int i,j,k,t,p; for(i=1... 阅读全文

posted @ 2011-04-30 22:07 more think, more gains 阅读(146) 评论(0) 推荐(0) 编辑

最短路

摘要: #include<stdio.h>#include<stdlib.h>int N,M;int map[110][110],dis[110],visit[110];const int inf=0x7fffffff;int dij(int x){ int i,j,k,t,p; for(i=0;i<=N;i++) { dis[i]=map[i][1]; visit[i]=0; } dis[0]=0; v... 阅读全文

posted @ 2011-04-30 21:48 more think, more gains 阅读(145) 评论(0) 推荐(0) 编辑

算法小结

摘要: 最短路算法: 1.dijkstra算法 2.bellman-ford算法 3.floyd 算法 最小生成树算法: 1.prim 2.kruskal 今天搞到头晕啦。 阅读全文

posted @ 2011-04-30 19:03 more think, more gains 阅读(205) 评论(0) 推荐(0) 编辑

福大校赛B题

摘要: #include<stdio.h>#include<string.h>int main( ){ char ch[200]; char sh[101][101]; while(scanf("%s",ch)!=EOF) { int i,j,len,k,p,flag=1,flag2=0; len=strlen(ch); i=0,k=0; while(i<len) { p=0; while(ch[i]>='a'&&ch[i]<='z'||(ch[i]>='A'&& 阅读全文

posted @ 2011-04-30 14:42 more think, more gains 阅读(142) 评论(0) 推荐(0) 编辑

畅通工程续

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>const int inf=0x7fffffff;int map[210][210],N,M,dis[210],visit[210];int dij(int x,int y ){ int i,j,t,k; for(i=0;i<N;i++) { dis[i]=map[x][i]; visit[i]=0; }for(i=0;i<N;i++) { t=inf; for(j=0;j<N;j++) { if(!visit[j]&& 阅读全文

posted @ 2011-04-30 13:01 more think, more gains 阅读(114) 评论(0) 推荐(0) 编辑

hdu 1233

摘要: #include<stdio.h>#include<algorithm>using namespace std;int father[110],N,M;struct node{ int i,j,v;}T[5000];int cmp(node a,node b){ return a.v<b.v;}int find(int x){ return x==father[x]?x:father[x]=find(father[x]);}void merge(int x,int y){ x=find(x); y=find(y); if(x!=y) father[x]=y;}in 阅读全文

posted @ 2011-04-30 11:13 more think, more gains 阅读(164) 评论(0) 推荐(0) 编辑

畅通工程 hdu 1223

摘要: #include<stdio.h>int father[1100],N,M;int find(int x){ return x==father[x]?x:father[x]=find(father[x]);}void merge(int x,int y){ x=find(x); y=find(y); if(x!=y) father[x]=y;}int main( ){ while(scanf("%d%d",&N,&M),N) { int i,j,a,b,count=1; for(i=1;i<=N;i++) father[i]=i; for( 阅读全文

posted @ 2011-04-30 11:00 more think, more gains 阅读(255) 评论(0) 推荐(0) 编辑

畅通工程

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>#include<algorithm>using namespace std;struct node{ int i; int j; int v;}T[5000];int father[110],rank[110];int N,M,t;int cmp(node a,node b){ return a.v<b.v;}int find(int x){ return x==father[x]?x:father[x]=find(father[x] 阅读全文

posted @ 2011-04-30 10:32 more think, more gains 阅读(140) 评论(0) 推荐(0) 编辑

继续畅通工程

摘要: #include<stdio.h>#include<stdlib.h>#include<algorithm>using namespace std;struct node{ int i,j,v,u;}T[10100];int father[10100],N,M;int cmp(node a,node b){ return a.v<b.v;}int find(int x){ return x==fa... 阅读全文

posted @ 2011-04-30 09:34 more think, more gains 阅读(152) 评论(0) 推荐(0) 编辑

as easy as A+B

摘要: #include<stdio.h>#include<algorithm>using namespace std;int A[100000];int main( ){ int N;scanf("%d",&N);while(N--){ int i,p;scanf("%d",&p);for(i=0;i<p;i++)scanf("%d",&A[i]);sort(A,A+p);for(i=0;i<p;i++)printf(i?" %d":"%d" 阅读全文

posted @ 2011-04-30 08:03 more think, more gains 阅读(216) 评论(0) 推荐(0) 编辑

导航