上一页 1 2 3 4 5 6 7 8 ··· 20 下一页

2014年12月14日

Poj1195&tyvj1474二维线段树

摘要: 二维树状数组模板题,熟悉下二维树状数组。tyvj1474#include #include #include #include #include #include #include #include #include #include #include #include using namespac... 阅读全文

posted @ 2014-12-14 16:01 一个西瓜 阅读(274) 评论(0) 推荐(0)

2014年11月26日

zoj2319Beautiful People Dp

摘要: 最长上升子序列的nlogn的解法,不过要注意的是 x按从小到大排序,y要按从大到小排序。对于同样的x,在维护的单调数组中y应该保留较小的那个。#include#include#include#include#include#include#include#includeusing namespace... 阅读全文

posted @ 2014-11-26 22:02 一个西瓜 阅读(180) 评论(0) 推荐(0)

zoj2315New Year Bonus Grant Dp

摘要: 树dp吧,就是它取了 就不能取它儿子,它儿子最多有一个可以取。然后对于每种dp[x][1] 表示 x 取了, dp[x][1] =∑ dp[son[x][0] +1,但是如果他是1 ,他自己不能取自己,这里要注意下。dp[x][0]= max((∑dp[son[x]][0])-dp[son[x]][... 阅读全文

posted @ 2014-11-26 21:58 一个西瓜 阅读(200) 评论(0) 推荐(0)

Poj2157Maze 搜索

摘要: 用一个5进制数来位压钥匙的状态,然后 判重就好了。 这题写戳了,反正是问能不能到,直接bfs 搜,打开一扇门在把它加入队列继续搜,看最后能不能搜到结果。#include#include#include#include#includeusing namespace std;int dx[] = {-1... 阅读全文

posted @ 2014-11-26 21:47 一个西瓜 阅读(145) 评论(0) 推荐(0)

BestCoder Round #18

摘要: 1001 Primes Problem打个10^4的素数表,枚举前两个搞一下就好了。#include#include#include#include#include#include#include#includeusing namespace std;const int n = 10000;int ... 阅读全文

posted @ 2014-11-26 21:30 一个西瓜 阅读(184) 评论(0) 推荐(0)

2014年11月15日

输入输出挂,手动扩栈。

摘要: //#pragma comment(linker, "/STACK:102400000,102400000") c++扩栈/* int __size__ = 256 '9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c =... 阅读全文

posted @ 2014-11-15 15:51 一个西瓜 阅读(682) 评论(0) 推荐(0)

Hdu5044Tree 树链剖分

摘要: 输入输出挂,扩栈挂,模板树链剖分。#include#include#include#include#include#include#includeusing namespace std;const int maxn = 111111;struct Node{ int next; int t... 阅读全文

posted @ 2014-11-15 15:41 一个西瓜 阅读(172) 评论(0) 推荐(0)

2014年11月14日

Codeforces Round #277 (Div. 2) LIS of Sequence Dp

摘要: 题意: 给出一个序列,问每个位置的元素,分别属于哪一类的东西。第一类 没有出现在任何的上升子序列中。 第三类 出现在所有上升子序列中 。第二类 就是剩下的了。。求两个东西 , dp[i] 表示 从1到 i 最长上升子序列的长度,dp1[i]表示从i到n 最长上升子序列的长度。设原序列最长上升子序列长... 阅读全文

posted @ 2014-11-14 18:25 一个西瓜 阅读(175) 评论(0) 推荐(0)

Codeforces Round #277 (Div. 2)Valid Sets 树DP

摘要: 题意:给出一棵树,并给出每个节点上的权值,求有多少个连通子块的最大值与最小值的差不超过d。对于每个顶点建立一颗树,然后找比它价值大的 或者 价值相等且之前没有被当作顶点建立树的点,这样就避免重复了。dp[x]表示包涵x且以x为顶点的连通子树的个数,dp[x] =∏ (dp[son[x]] + 1... 阅读全文

posted @ 2014-11-14 18:19 一个西瓜 阅读(190) 评论(0) 推荐(0)

2014年11月8日

Poj1330Nearest Common Ancestors LCA

摘要: 题意给一颗树,再给一个查询两点之间的最近公共祖先。#include#include#include#include#includeusing namespace std;const int maxn = 111111;struct edge{ int to; int next;}e[maxn ... 阅读全文

posted @ 2014-11-08 16:14 一个西瓜 阅读(185) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 20 下一页

导航