摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1560思路:关键是启发式函数h()的构造,我们可以这样想:每次给主串增加一个字符和字符串的最后一位比较,如果相同,这个字符串的长度减一。构造h()为当前所有字符串中长度最长的。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 char map[10][10]; 8 char str[10]="ACGT"; 9 int len[10];10 int n,maxdeep;11 12 bool 阅读全文
posted @ 2013-09-17 21:07 ihge2k 阅读(692) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2234思路:IDA*可以搞,借鉴的是大牛的启发式函数h(): 可以考虑把每一行上的数转化成相同的,或者把每一列上的数字转化成相同的,二者取最小值。1 1 3 22 4 4 2 3 3 1 41 2 3 4如果把这个矩阵转化成行相同的话需要的操作:第一行 至少要2次,第二行也是2次, 第三行是2次,第四行是3次, 所以把矩阵转化成行相同至少要3次。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 ... 阅读全文
posted @ 2013-09-17 20:06 ihge2k 阅读(393) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1667思路:大牛说是IDA*的入门题=.=构造h()=8-max(1,2,3); max(1,2,3)表示中间的八个位置中出现最多的数的个数。 因为每次操作只能改变中间8个中的一个,所以可以这样构造启发式函数。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int map[10][10]; 8 int maxdeep; 9 char ans[111]; 10 11 b... 阅读全文
posted @ 2013-09-17 18:55 ihge2k 阅读(245) 评论(0) 推荐(0) 编辑