摘要:https://www.luogu.com.cn/problem/UVA816 朝向也包含在节点状态里 // UVa816 Abbott's Revenge // Rujia Liu #include<cstdio> #include<cstring> #include<vector> #inclu
阅读全文
摘要:Optimal Programs As you know, writing programs is often far from being easy. Things become even harder if your programs have to be as fast as possible. And sometimes there is reason for them to ...
阅读全文
摘要:例7-3 倒水问题。 有装满水的6升的杯子、空的3升杯子和1升杯子,3个杯子中都没有刻度。在不使用其他道具的情况下,是否可以量出4升的水呢? 方法如图7-7所示。 图7-7 倒水问题:一种方法是(6,0,0)→(3,3,0)→(3,2,1)→(4,2,0) 注意:由于没有刻度,用杯子x给杯子y倒水时必须一直持续到把杯子y倒满或者把杯子x倒空,而不能中途停止。 你的任务是解决一般性...
阅读全文
摘要:学习点: scanf可以自动过滤空行 搜索时要先判断是否越界(L R C),再判断其他条件是否满足 bfs搜索时可以在入口处(push时)判断是否达到目标,也可以在出口处(pop时) #include#include#include#include#includeusing namespace std;const int N=31;const int dl[]={-...
阅读全文
摘要:bfs 最短路径 #include#include#include#include#include#includeusing namespace std;const int N=105;int n, m, rs, cs, rt, ct;typedef int A[N][N];A maze, vis, dist, last_dir;int dr[] = {-1,1,0,0};int dc...
阅读全文
摘要:// 题意:输入标准国际象棋棋盘上的两个格子,求马最少需要多少步从起点跳到终点 BFS求最短路: bfs并维护距离状态cnt, vis记录是否访问过 #include#include#include#include#include#includeusing namespace std;int r1, c1, r2, c2;const int N=8;int vis[N][N];...
阅读全文