HOJ 2064 Journey to Tibet (DP)
摘要:题目中要求只要两个村庄间的距离小于等于30就可以转移。而刚开始我以为这个人最多只能走30,转移的路超过30之后就不能再转移了。刚开始用的BFS,怎么写都超时。后来发现看错题了之后,果断换成了DFS,然后才AC。本来挺简单的一道,浪费了大半天的时间。。不过最后能过掉还是很开心的。。#include <iostream>
#include <cstdio>
#include <stack>
#include <memory.h>
using namespace std; struct Village
{ int x; int y; int monas
阅读全文
posted @
2012-08-24 16:53
MicZ
阅读(198)
推荐(0)
HOJ 1447 Compromise (DP)
摘要:是一道要记录公共子序列内容的DP。状态转移方程部分:for(int i=1; i<=len1; i++) { for(int j=1; j<=len2; j++) { if(!strcmp(str1[i],str2[j])) { f[i][j]=f[i-1][j-1]+1; } else { f...
阅读全文
posted @
2012-08-24 16:49
MicZ
阅读(177)
推荐(0)