摘要: http://poj.org/problem?id=1159题目大意:给定一个字符串,问最少插入多少字符,使该字符串变成回文字符串。设原字符串序列为X,逆序列为Y,则最少需要补充的字母数=X的长度-X和Y的最长公共子串的长度。状态转移方程:f[i][j]=max{f[i-1][j],f[i][j-1],f[i-1][j-1]+1(ifs1[i]==s2[j])}#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector& 阅读全文
posted @ 2013-04-04 15:59 aiiYuu 阅读(181) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1003现在真是老了,还记得很久以前写过很多动态规划题的,现在都忘了,又得从新开始了~(@^_^@)~状态转移方程:f[i]=f[i-1]>=0?f[i-1]+a[i]:a[i].终点t就是最大的f值对应的i,起点从t顺推到不连续就行了(连续的情况是:f[i]+a[i]==f[i+1])#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include < 阅读全文
posted @ 2013-04-04 15:12 aiiYuu 阅读(141) 评论(0) 推荐(0)
摘要: http://codeforces.com/contest/288/problem/Bans = k^(k-1) * (n-K)^(n-k).#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;temp 阅读全文
posted @ 2013-04-03 02:17 aiiYuu 阅读(253) 评论(0) 推荐(0)
摘要: 状态空间搜索http://zhan.renren.com/aiiyuu?from=bar本文为aiiYuu精心整理,转载请注明出处O(∩_∩)O--aiiYuu状态(ststus)是对问题在某一时刻的进展情况的数学描述;状态转移(state-transition)是问题从一种状态转移到,另一种(或几种)状态的操作。搜索的目的:判断智能体(agent)能否从起始状态(startstate)到达目标状态(goalstate)。智能体数量>1=>多人博弈状态空间:搜索的目的实际上是在遍历一个隐式图,他的节点是所有的状态,有向边对应于状态的转移,而一个可行解就是一条从起始节点出发到达目标状 阅读全文
posted @ 2013-04-02 19:46 aiiYuu 阅读(3009) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1043经典八数码问题的启发式搜索#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <cla 阅读全文
posted @ 2013-04-02 01:16 aiiYuu 阅读(235) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2449A*搜索求K短路。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <class T> void checkm 阅读全文
posted @ 2013-04-01 16:52 aiiYuu 阅读(138) 评论(0) 推荐(0)
摘要: 2013腾讯编程马拉松初赛第〇场(3月20日)题解4500小Q系列故事——屌丝的逆袭简单模拟#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <class T> void 阅读全文
posted @ 2013-04-01 16:29 aiiYuu 阅读(150) 评论(0) 推荐(0)
摘要: Edmondskarp算法中文翻译,转载请注明出处http://zhan.renren.com/aiiyuu?from=bar--aiiYuu.(以下两页是原文内容,来自网络:http://www.cs.cornell.edu/courses/cs4820/2010sp/handouts/edmondskarp.pdf)Edmonds-Karp最大流算法导论这部分内容展现了Edmonds-Karp最大流算法的内容。在这里假设我们的读者都了解了残留图,增广路,以及网络最小割的概念。在这里我们先了解一下Ford-Fulkerson算法(aiiYuu注:也是一种求最大流的算法),算法的伪代码如下:算 阅读全文
posted @ 2013-04-01 02:47 aiiYuu 阅读(612) 评论(0) 推荐(0)
摘要: 对于DancingLinksX算法接精确覆盖的解释之前写的hust1017精确覆盖的代码,鉴于有的同学可能不是很了解其性能,所以对之前的代码进行展开解释。const int N = 1100 , V = 102020;int U[V] , D[V] , L[V] , R[V] , C[V];int H[N] , S[N] , mark[V];int size , n , m , OK[N] , flag;void Link(int r,int c) {Link(r,c)表示在第r行第c列插入一个“1”元素 S[c] ++; C[size] = c; //C[size]表示第size个元... 阅读全文
posted @ 2013-03-31 08:02 aiiYuu 阅读(140) 评论(0) 推荐(0)
摘要: http://acm.hust.edu.cn/problem.php?id=1017ThereisanN*Mmatrixwithonly0sand1s,(1<=N,M<=1000).Anexactcoverisaselectionofrowssuchthateverycolumnhasa1inexactlyoneoftheselectedrows.Trytofindouttheselectedrows.DLX接精确覆盖#include <cstdio>#include <cstring>#include <iostream>#include &l 阅读全文
posted @ 2013-03-31 02:19 aiiYuu 阅读(163) 评论(0) 推荐(0)