![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
poj
qingniaofy
这个作者很懒,什么都没留下…
展开
-
poj 2488 DFS水过
题目给出 n行m列的棋盘,问马可以全部的棋盘格都走过一遍吗,马以 L 型走 很土的办法,枚举起点,然后进行dfs并记录路径,注意要输出 字典序最小的一条路径,所以按照 程序中的 dx,dy方向数组就可以搞定了。。 #include #include #include #include using namespace std; const int maxn = 30原创 2013-02-28 20:39:02 · 3114 阅读 · 0 评论 -
poj 1083 Moving Tables
思路: 将 房间1和2 之间的走廊标记为1,3和4之间的标记为2.。。 根据给出的 搬动桌子的 起始房间 到 终点房间 求出 占用的走廊编号,具体为 (房间编号+1)/2 即为走廊编号 每段走廊编号上的记录 数组 有占用就 +1 最后求出占用最多的*10 就是答案了 注意 房间的 起始和终止 编号大小,起始 #include #include #include #include us原创 2013-03-15 00:04:36 · 940 阅读 · 0 评论 -
poj 1321 棋盘问题
思路:dfs,按行顺序,一行一行往下搜索,对 列 进行判断是否已经占领即可 #include #include #include #include using namespace std; const int maxn=10; char map[maxn][maxn]; bool usedy[maxn]; int n,k,ans; void dfs(int x,int cnt){ if原创 2013-03-16 22:13:17 · 774 阅读 · 0 评论 -
poj 2251 Dungeon Master
题意:给出一个3D迷宫,要求从起点到终点的最少步数。 思路:其实跟二维的迷宫一样,只要进行一次BFS即可。。 #include #include #include #include using namespace std; struct Node{ int x,y,z; int step; bool operator == (const Node& cmp)const{原创 2013-03-17 15:03:23 · 710 阅读 · 0 评论 -
poj 3278 Catch That Cow
直接 bfs,没啥说了 #include #include #include #include using namespace std; int s,e,ans; int queue[2000000]; bool visited[100002]; bool ok(int n){ return n>=0&&n<=100000; } void bfs(){ int front,原创 2013-04-10 19:30:56 · 663 阅读 · 0 评论 -
poj 3126 Prime Path
给出两个素数a,b,要求a每次改变一位数,最后要几步才能变成b,a每次改变完也必须是素数 #include #include #include #include #include using namespace std; const int maxn=10000; int prime[maxn]; bool flag[maxn]; int pcnt; int queue[maxn原创 2013-04-18 20:51:36 · 679 阅读 · 0 评论