2012年2月17日

poj-3250 Bad Hair Day **

摘要: 1 /* 2 * DA-term-Bad Hair Day.cpp 3 * 4 * 这是一种解法,还可以用 “单调队列” 来做(见后。。) 5 * 6 * Created on: 2011-12-2 7 */ 8 9 #include <iostream>10 using namespace std;11 12 const int maxn = 80000 + 5;13 14 int h[maxn], n;15 int num[maxn], cow[maxn]; //num[i]:第i头牛能看到的牛数16 //cow[i]:在第i头牛东边第一个比i高的牛17 18... 阅读全文

posted @ 2012-02-17 18:46 龙豆 阅读(244) 评论(0) 推荐(0)

poj-1159 Palindrome **

摘要: 1 /* 2 * DA-term-Palindrome.cpp 3 * 4 * DP 5 * 6 * 动态规划求解。 7 8 设ch[1]..ch[n]表示字符串1至n位,i为左游标,j为右游标 ,则i从n递减,j从i开始递增。 9 min[i][j]表示i和j之间至少需要插入多少个字符才能对称,初始置全0 ,我们最终需要得到的值是min[1][n].10 则11 if(ch[i]==ch[j]) //如果两个游标所指字符相同,向中间缩小范围12 mi... 阅读全文

posted @ 2012-02-17 18:43 龙豆 阅读(180) 评论(0) 推荐(0)

poj-1080 Human Gene Functions **

摘要: 1 /* 2 * Human Gene Functions.cpp 3 * 4 * Created on: 2011-12-9 5 * 6 * 类似 最长公共子串 7 */ 8 9 #include <cstdio>10 using namespace std;11 12 const int maxn = 100 + 5;13 14 const int s[5][5] = {{5, -1, -2, -1, -3}, //分数矩阵15 {-1, 5, -3, -2, -4},16 ... 阅读全文

posted @ 2012-02-17 18:40 龙豆 阅读(259) 评论(0) 推荐(0)

poj-1733 Parity game ****

摘要: 1 /* 2 * poj-1733 Parity game.cpp 3 * 4 * Created on: 2012-2-17 5 * Author: LongDou 6 * 7 * 8 * hash离散化 + 并查集 9 * 10 * 设s[0]=0,s[i]=a[1]+a[2]+...+a[i],则信息i j even等价于a[i]+...+a[j]为偶数,即 11 s[j]-s[i-1]为偶数,即s[j]与s[i-1]同奇偶。这样,每条信息都可以变为 12 s[i-1]和s[j]是否同... 阅读全文

posted @ 2012-02-17 17:12 龙豆 阅读(592) 评论(1) 推荐(1)

导航