上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2918思路:这道题与前面几道类似,可以说是被秒杀了!!!构造启发式函数h()=(cnt+3)/4(cnt为不在位的点的个数)。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int map[4][4]; 8 char str[14]; 9 int max_deep; 10 11 int Get_H() 12 { 13 int cnt=0; 14 for(int i=1... 阅读全文
posted @ 2013-09-18 11:09 ihge2k 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1813思路:首先bfs预处理出‘0’到边界点最短距离,然后构造 h() 为所’0‘点逃离迷宫的最少步数的最大值。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define inf 1PP; 9 10 struct Node{ 11 int x,y; 12 }node[44]; 13 14 char str[11][11]; 15 int map[11][1... 阅读全文
posted @ 2013-09-18 10:17 ihge2k 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 题目链接: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) 编辑
摘要: 题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=21261思路:此题需要记忆化搜索,dp[x][y][t]表示当前状态下是否是否有可能点(x,y)上有贼,0表示不可能,1表示可能,然后及时记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 111 8 typedef pairPP; 9 10 int n,m,Time,cnt;11 int dp[MAXN][MAXN] 阅读全文
posted @ 2013-09-16 22:05 ihge2k 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3904思路:费用流的题,增加一个超级源点和一个超级汇点,然后就是连边了,对于每个城市,与汇点连边,容量为inf,花费(这里指收益)为商品在该城市的价值,然后对于图中给定的边,容量为cap,花费为-cost(负数代表花费),最后就是源点与城市1连边了,然后就是跑费用流了,求最大收益(当dist[vt] 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 22 阅读全文
posted @ 2013-09-16 20:02 ihge2k 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734思路:记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int Pow[11]; 7 int dp[11][5050]; 8 int digit[11]; 9 int a,b;10 11 int Get_f(int n)12 {13 int pos=0,res=0;14 while(n){15 digit[pos++]=n%10;16 n/=10... 阅读全文
posted @ 2013-09-16 14:49 ihge2k 阅读(575) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4739思路:状态压缩。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct Point{ 9 int x,y;10 }point[22];11 12 int dp[(1g[22];35 int main()36 {37 while(~scanf("%d",&n)){38 if(n==-1)break;39 for(int i=... 阅读全文
posted @ 2013-09-15 21:14 ihge2k 阅读(581) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=23727思路:首先是Tarjan找桥,对于桥,只能是双向边,而对于同一个连通分量而言,只要重新定向为同一个方向即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define MAXN 111110 typedef pairPP;11 12 int low[MAXN],dfn[MAXN];13 bool 阅读全文
posted @ 2013-09-15 10:10 ihge2k 阅读(266) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 61 下一页