2013年3月7日
摘要: 题目链接:http://poj.org/problem?id=3370DescriptionEvery year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets on that day, no matter how many children call on him, so it may happen that a child will get nothing if it is too late. To avoid co 阅读全文
posted @ 2013-03-07 18:38 crying_Dream 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2356DescriptionThe input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your task is to choose a 阅读全文
posted @ 2013-03-07 18:37 crying_Dream 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010题目大意:一只狗受到了骨头的诱惑,进了n*m的迷宫,迷宫的大门在第T秒开启。小狗要恰好在T秒到达。并且.只能走一次。解题思路:BFS求最短时间,这里并不适合。因此dfs.dfs有3个状态dfs(i, j, t),表示到达(i, j)花费t秒。这里要有剪枝:剪枝1.目标状态(x1, y1),现在状态dd=(x2, y2) abs(x1-x2)+abs(y1-y2))表示现在状态到达目标状态的距离tt=T-t表示还需要走的时间,if(tt-dd<0||(tt-dd)%2) return ; 阅读全文
posted @ 2013-03-07 18:34 crying_Dream 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1562题目大意:就是找有多少个油田,在垂直或者水平或者垂直方向上相邻都算作是属于同一个油田。解题思路:如果遇到@的话就进行八个方位搜索,然后搜索到@变成*避免重复搜索。 代码如下:View Code #include<stdio.h>#include<string.h>char map[102][102];int dir[8][2]={{0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}};int m, n;void dfs 阅读全文
posted @ 2013-03-07 18:31 crying_Dream 阅读(225) 评论(0) 推荐(0) 编辑