摘要: 坑爹啊。。。 这道题不难但是还是wa了四次,首先该图必须连通的**,其次房间号码大小不一定从1开始,所以他的大小可以随意的,在初始化的时候需要将持续到MAXN,当直接输入0 0的时候输出的是YES,还有就是虽然集合合并后,但是father还不一定相同,必须Find后才能相同#includeconst... 阅读全文
posted @ 2012-08-06 19:31 calmound 阅读(266) 评论(0) 推荐(0)
摘要: void Make_set(int n){ for(int i=0;irank[y]) { father[y]=x; } else { //rank[x]<rank[y],也是father[x]=y,所以省略 if(rank[x]==rank... 阅读全文
posted @ 2012-08-06 15:58 calmound 阅读(165) 评论(0) 推荐(0)
摘要: 题意:找几个不相连的团体,最后查找发现只要father有几个是自己的,就有几个团队,这个我没想到#include#includeconst int MAXN=1010;int father[MAXN],rank[MAXN];int hash[MAXN];void Make_set(int n){ ... 阅读全文
posted @ 2012-08-06 15:57 calmound 阅读(194) 评论(0) 推荐(0)
摘要: 01dp不过由于数组过于大,开不开,学了搜索过了,先记录下 还有一种方法#include#includeusing namespace std;const int MAXN=10000010;int a[MAXN];int n,m,ans;bool cmp(int a,int b){ retu... 阅读全文
posted @ 2012-08-05 20:49 calmound 阅读(231) 评论(1) 推荐(0)
摘要: 题意:求最大矩阵和将二维转化为一维的#include#includeint main(){ int n,i,j,k; int map[130][130],mSum[130]; while(scanf("%d",&n)!=EOF) { int max=-10000... 阅读全文
posted @ 2012-08-04 15:42 calmound 阅读(191) 评论(0) 推荐(0)
摘要: 给定一个物品集合s={1,2,.....,n},物品i具有重量wi和价值vi。背包能承受能承受的最大载重量不超过W。背包问题就是找到一个物品子集s‘属于s,使得maxEwi1它进不了背包,背包容量为2时,进入背包,所以背包容量最大价值为12;背包容量为3,4,5时都可以进入背包,价值均为12。 ... 阅读全文
posted @ 2012-08-02 20:21 calmound 阅读(286) 评论(0) 推荐(0)
摘要: 最大子窜和,用b记录当前的和,用sum记录最大的和,当bint main(){ int a[100010]; int T,i,b,sum,n,t1,t2; int cas=1,x; scanf("%d",&T); while(T--) { scanf... 阅读全文
posted @ 2012-07-31 10:02 calmound 阅读(179) 评论(0) 推荐(0)
摘要: We all love recursion! Don't we?Consider a three-parameter recursive function w(a, b, c):if a 20 or b > 20 or c > 20, then w(a, b, c) returns:w(20, 2... 阅读全文
posted @ 2012-07-30 10:43 calmound 阅读(183) 评论(0) 推荐(0)
摘要: 从顶到底的最大和是多少#include#includeint main(){ int n,i,j; int a[110][100]; int sum[110]; int ans; while(scanf("%d",&n)!=EOF) { for (i... 阅读全文
posted @ 2012-07-30 09:47 calmound 阅读(158) 评论(0) 推荐(0)
摘要: uva的题真的很好,每个题都能长许多知识,A了后很开心,这道题我用了两天写,只一道题就学了四个函数,成长不少Problem E: Automatic EditingSource file:autoedit.{c,cpp,java,pas}Input file:autoedit.inOutput fi... 阅读全文
posted @ 2012-07-28 10:02 calmound 阅读(323) 评论(0) 推荐(0)