摘要: 题目大意和思路同上题类似, 本题特殊点为其需要将多组满足要求的结果按递增全部输出。解题代码: View Code #include<stdio.h>#include<string.h>#include<stdlib.h>using namespace std;#define MAX(a,b) (a)>(b)?(a):(b)#define MIN(a,b) (a)<(b)?(a):(b)const int N = 50010;int M[N], n;int head[N], idx;struct node{ int max, sum;}D[N];s 阅读全文
posted @ 2012-12-18 12:02 yefeng1627 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 解题思路: 树重心,将其与其最大子树连接的边,删除后,划分出的两个子树节点数量最大的中的最小. 题目其实是树的重心的一点变异。 树的重心是 树中所有节点的字节点数量最大中的最小的节点 O(n) 求出每个点的的子节点的最大值以及其字节点总个数,然后在线性比较下就可以求出重心了, 此题要注意, 这里要求的是 所有的(节点的子节点数量的最大值)中最小的. 解题代码: View Code #include<stdio.h>#include<string.h>#include<stdlib.h>using namespace std;#define MAX(a,b) 阅读全文
posted @ 2012-12-17 22:46 yefeng1627 阅读(688) 评论(0) 推荐(0) 编辑
摘要: 关于分治算法在树上的应用详情请查看09年QZC国家集训队论文。题目大意: 树含N个点,点之间有权值,求两点间权值和小于等于K的点对数量( N <= 10000 )解题思路:对于以rt为根节点的树,其树上两点间一条路径只有两种情况,分别为过根节点,不过根节点。 这样,启发了我们使用分治的思想来解决此题。 若不过根节点,则通过递归处理,其实也可理解为过根节点,但过了根的那部分为0.可简化代码 若过根节点, 则 dist(i)+dist(j) <= K 且 father(i) != father(j) 其中哦功能 dist(i) 为 子树上节点到根节点rt的距离, fath... 阅读全文
posted @ 2012-12-17 13:35 yefeng1627 阅读(258) 评论(0) 推荐(0) 编辑
摘要: du熊填数字Time Limit:3000/2000 MS (C/Others) Memory Limit: 65536/32768 K (C/Others)本次组委会推荐使用C、C++Problem Description du熊这几天使劲的往一个n 行n列的矩阵填0和1这两个数字,n为偶数,而且矩阵由里向外分成了n / 2层。比如n = 6时,矩阵的分层如下: du熊填数时有一个要求:不能存在两个相邻的1,且位于不同的层(这里的相邻指两格子共用一条线)。 请你帮du熊计算一下有多少种填法。Input 输入包含多组测试数据,每组数据包含一个偶数n (2 <= n <= 500)。 阅读全文
posted @ 2012-12-11 22:09 yefeng1627 阅读(414) 评论(5) 推荐(0) 编辑
摘要: du熊学斐波那契ITime Limit : 2000/1000ms (C/Other)Memory Limit : 65535/32768K (C/Other)本次组委会推荐使用C、C++Problem Descriptiondu熊对数学一直都非常感兴趣。最近在学习斐波那契数列的它,向你展示了一个数字串,它称之为“斐波那契”串:11235813471123581347112358........聪明的你当然一眼就看出了这个串是这么构造的:1.先写下两位在0~9范围内的数字a, b,构成串ab;2.取串最后的两位数字相加,将和写在串的最后面。上面du熊向你展示的串就是取a = b = 1构造出来 阅读全文
posted @ 2012-12-11 22:08 yefeng1627 阅读(274) 评论(0) 推荐(0) 编辑
摘要: C. Anagramtime limit per test1 secondmemory limit per test256 megabytesStringxis ananagramof stringy, if we can rearrange the letters in stringxand get exact stringy. For example, strings "DOG" and "GOD" are anagrams, so are strings "BABA" and "AABB", but stri 阅读全文
posted @ 2012-12-10 23:08 yefeng1627 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 题目大意: 有K个挤奶器,C头奶牛,每个挤奶器最多能给M头奶牛挤奶。求使C头奶牛头奶牛需要走的路程的最大路程最小。解题思路: 使用Floy预先求出任意两点间最短距离,然后二分枚举最大距离. 构图方案: 源点与奶牛连边,容量为1, 挤奶器与汇点连边,容量为M, 奶牛与挤奶器连边 (注意,这里只有单项边) 还要注意的是,因为预先求过最短路,初始化的时候对于0的边,赋值的无穷大不要设的太大,不然会溢出.参考代码: SAP(shortest augment path) 间隙优化, AC时间 110ms View Code #include<stdio.h>#include<stdli 阅读全文
posted @ 2012-12-10 21:13 yefeng1627 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 解题思路: 源点为1,汇点为N, 直接求最大流就好View Code #include<stdio.h>#include<string.h>#include<string.h>#define MIN(a,b) (a)<(b)?(a):(b)const int inf = ~0u>>1;const int MAXN = 210;int n, m, S, T, N;int head[MAXN], idx, h[MAXN], vh[MAXN];struct Edge{ int v, f, nxt; }edge[MAXN<<4];voi 阅读全文
posted @ 2012-12-10 19:39 yefeng1627 阅读(144) 评论(0) 推荐(0) 编辑
摘要: PIGSTime Limit:1000MSMemory Limit:10000KTotal Submissions:12924Accepted:5721DescriptionMirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys to s 阅读全文
posted @ 2012-12-10 19:06 yefeng1627 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 1017: Fast TransportationTime Limit:10 SecMemory Limit:128 MBSubmit:72Solved:11DescriptionI’m working for a huge transportation company, and this month we get a job that deliver K important medicinal machines from city S to city T. Since the machines is so large that for each machine we should use a 阅读全文
posted @ 2012-12-09 22:35 yefeng1627 阅读(313) 评论(0) 推荐(0) 编辑

Launch CodeCogs Equation Editor