poj 3009 (深搜求最短路)】的更多相关文章

题目大意就是求在特定规则下的最短路,这个规则包含了消除障碍的操作.用BFS感觉选择消除障碍的时候不同路径会有影响,用DFS比较方便状态的还原(虽然效率比较低),因此这道题目采用DFS来写. 写的第一次提交代码是TLE,原因是忘记总步数>10就应该剪枝的条件.AC代码如下: #include <cstdio> #include <algorithm> #include <iostream> using namespace std; ; struct Point{ i…
POJ 3009 题意: 给出一个w*h的地图,其中0代表空地,1代表障碍物,2代表起点,3代表终点,每次行动可以走多个方格,每次只能向附近一格不是障碍物的方向行动,直到碰到障碍物才停下来,此时障碍物也会随之消失,如果行动时超出方格的界限或行动次数超过了10则会game over .如果行动时经过3则会win,记下此时行动次数(不是行动的方格数),求最小的行动次数 #include<cstdio> #include<iostream> #include<cstring>…
题目链接:http://poj.org/problem?id=3635 题意题解等均参考:POJ 3635 - Full Tank? - [最短路变形][优先队列优化Dijkstra]. 一些口胡: 说实话,上次写类似的二维状态最短路Gym 101873C - Joyride - [最短路变形][优先队列优化Dijkstra],我没能把手写二叉堆优化Dijkstra的给写出来. 这次费了点功夫,也算是给写出来了,需要注意的点还是有点多的.而且我终于深刻理解为啥不推荐手写二叉堆了,主要是代码量相比…
题目来源:http://poj.org/problem?id=3009 一道深搜题目,与一般搜索不同的是,目标得一直往一个方向走,直到出界或者遇到阻碍才换方向. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<cmath> 6 #include<algorithm> 7 #include<queu…
http://poj.org/problem?id=3009 一个搜索的题目: 大意就是一个冰球,在冰面上滑动,你打击一次,就沿一个反向滑动,知道碰到墙就会停下,而墙则会破碎. 求从起点到终点的最短的击打次数. 题目中 2代表起点,3是终点,1是墙,0则是光滑的. #include <stdio.h> ][],step,xs,ys,xe,ye,steps; ][]={-,,,-,,,,}; void dfs(int x,int y) { ) return; ;i<;i++) { ],m=…
http://poj.org/problem?id=3009 如果目前起点紧挨着终点,可以直接向终点滚(终点不算障碍) #include <cstdio> #include <cstring> using namespace std; ; int maz[maxn][maxn]; int n,m; ] = {,-,,}; ] = {,,,-}; bool in(int x,int y) { && x < n && y >= &&a…
题目链接:http://poj.org/problem?id=2449 "Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story. "Prince Remmarguts lives in his kingdom UDF – Unite…
http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6776   Accepted: 1822 Description Lily runs a repairing company that services the Q blocks in the city. One day the company receives M repa…
Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24249   Accepted: 8652 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way pa…
题目:http://poj.org/problem?id=3009 参考博客:http://www.cnblogs.com/LK1994/ #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<iomanip> #include<cmath>…