随笔分类 - POJ
摘要:题意: 找出树上异或和最大的一条路径$p$ $$ _{xor}length(p)=\oplus_{e\in_p}w(e) $$ 01字典树。同样用到了简单的异或性质 $0\oplus a = a, a\oplus a = 0$ 定义$f(u,v)$为$u$到$v$的路径异或和。那么$f(u,v) =
阅读全文
摘要:Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others. Farmer John has cooked fabulous
阅读全文
摘要:题目链接 就是裸的最小生成树,复习一下。 prim算法: G=(V,E),V是点集,E是边集 假设T=(U,TE)是最小生成树。U,TE初始化为空 首先从V中任取一点 假设取V1,然后U={V1},只要U是V的真子集,就从那些一个端点在T中,一个端点在T外的边中,找一条最短边。一直下去,直到找到n-
阅读全文
摘要:The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of
阅读全文
摘要:The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies
阅读全文
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate
阅读全文
摘要:For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultim
阅读全文
摘要:You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number
阅读全文
摘要:放苹果 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 37515 Accepted: 23090 Description 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1
阅读全文
摘要:Treats for the Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7949 Accepted: 4217 Description FJ has purchased N (1 <= N <= 2000) yum
阅读全文
摘要:Help Jimmy Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14214 Accepted: 4729 Description "Help Jimmy" 是在下图所示的场景上完成的游戏。 场景中包括多个长度和高度各不相同的
阅读全文
摘要:题目:http://poj.org/problem?id=2503题目大意:就是后面字符串映射前面字符串,然后查询输出。直接map,不过也可以考虑字典树解决;AC代码:#include#include#include#includeusing namespace st...
阅读全文
摘要:题目:http://poj.org/problem?id=2531题目大意:给你N个点,然后以矩阵形式给你了 Cij 的权值, 然后让你把这N个点,分成两部分,使 值最大。思路:显然对于深搜极差的我体验感极差,首先分为 0,1 集合,在1里面就减,在0里面就加...
阅读全文
摘要:题目:http://poj.org/problem?id=3278 思路:从n到k,每步有3种走法,根本没有发现用bfs可以完美解决问题。方法非常巧。其实也是正常解法,平时做的bfs都是6或8个方向并且是2维的,但是换做3种走法还是一维的就感觉很神奇,说明没有真正理解...
阅读全文
摘要:题目:http://poj.org/problem?id=2488题目大意:可以从任意点开始,只要能走完棋盘所有点,并要求字典序最小,不可能的话就impossible;思路:dfs+回溯,因为字典序最小,如果可以的话,肯定是从(1,1)开始的。然后递归搜索该点的所有方...
阅读全文
摘要:题目:http://poj.org/problem?id=2456思路:二分经典题目,二分答案,判断间隔mid是否能容纳所有的奶牛。不过二分坑点比较多例如查找值的时候,while里面写 r, 前一个状态下的 l+1 了,所以最后返回 l-1(纯属个人理解)推荐二...
阅读全文
摘要:题目:http://poj.org/problem?id=2229题目大意:就是拆分n 每一位都得是2的幂。 注意4 :1111 112 22 4 一共4种递推:对于n可以分为是奇数还是偶数奇数:肯定有1, 和去掉一个1的情况一样 所以 dp[i...
阅读全文
摘要:题目:acm.hdu.edu.cn/showproblem.php?pid=2050递推:从直线入手,第n条直线,最多和平面上的直线有n-1个交点,多出(n-1)+1个部分序号 1 2 3 ... n 交点 0 1 2 ... ...
阅读全文
摘要:题目链接AlignmentTime Limit: 1000MS Memory Limit: 30000K Total Submissions: 18497 Accepted: 6060 DescriptionIn the army, a p...
阅读全文
摘要:题目链接:点击打开链接 思路:参考资料后,两种方法:①就是开3倍空间,然后和普通并查集一样,但是关系不太好理解。②向量偏移方法一:有好几种理解方式,还是书上的好理解:x-A x-B x-C y-A y-B y-C AC代码:代码断点1处...
阅读全文

浙公网安备 33010602011771号