合集-BFS
摘要:#include<iostream> #include<queue> #include<cstring> const int N=10010; int t,aa,bb,prime[N],vis[N],step[N]; using namespace std; void prime_(){ //埃式筛
阅读全文
摘要:#include<iostream> #include<queue> #include<cstring> using namespace std; const int N=1e5+10; int n,k,line[N],way; struct node{int loc,step;}; queue<n
阅读全文
摘要:Problem - 1312 (hdu.edu.cn) BFS模板题 #include<iostream> #include<queue> using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; int wx,hy,n
阅读全文
摘要:Problem - 4460 (hdu.edu.cn) 写完提交答案错了,后面发现vis初始化的地方错了,以前BFS都只调用一次,看来我中毒太深。这个题更能体现BFS的特性,增加dis数组记录距离。 #include<iostream> #include<queue> #include<cstrin
阅读全文
摘要:Problem - 1240 (hdu.edu.cn) 三维的BFS,存在一个坐标点的变换,即输入的是 (y , z , x),进行转换即可 #include<iostream> #include<queue> #include<cstring> using namespace std; int n
阅读全文
摘要:3414 -- Pots (poj.org) 这道题需要输出最后结果的执行过程,可以通过结构体,在结构体中定义一个数组s,s中存储了每一步的执行过程,实现了回溯。并且在运行中可以适当剪枝,减少枚举次数。 #include<iostream> #include<queue> #include<cstr
阅读全文

浙公网安备 33010602011771号