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)

导航