随笔分类 -  搜索—bfs

该文被密码保护。
posted @ 2019-04-02 14:37 lokiii 阅读(8) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-03-31 11:49 lokiii 阅读(5) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-11-14 16:02 lokiii 阅读(23) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-10-23 19:17 lokiii 阅读(2) 评论(0) 推荐(0)
摘要:萧天佐摆天门两国交战 老娘亲押粮草来到北番 我有心回宋营见母一面 怎奈我身在番不能过关 阅读全文
posted @ 2018-10-11 10:22 lokiii 阅读(248) 评论(0) 推荐(0)
摘要:你不该人前逞骄傲 不该词费又滔滔 阅读全文
posted @ 2018-10-02 15:52 lokiii 阅读(122) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-09-26 11:20 lokiii 阅读(1) 评论(0) 推荐(0)
摘要:因为边权为1所以a直接bfs瞎搞就行……我一开始竟然写了个spfa cpp include include include include using namespace std; const int N=1005,inf=1e9; int n,m,st,ed,h[N],cnt,a[N][N],b[ 阅读全文
posted @ 2018-09-21 21:57 lokiii 阅读(112) 评论(0) 推荐(0)
摘要:spfa预处理出最短路数组dis,然后反向建边bfs出ok[u]表示u能到n点 然后发现有0环的话时候有inf解的,先dfs找0环判断即可 然后dfs,设状态f[u][v]为到u点,还可以跑最短路+v的长度,记忆化,然后直接搜即可 cpp include include include includ 阅读全文
posted @ 2018-09-15 07:50 lokiii 阅读(152) 评论(0) 推荐(0)
摘要:调死我了…… 首先观察移动方式,需要移动的格子每次移动到相邻格子,一定是先把空白格子挪过去,所以我们得到一种做法,就是bfs预处理出每一个格子的四联通格子之间的空白格子移动距离建边,注意这个移动是不能经过当前枚举的中心格子的,然后把中心格子和它的四联通格子建边权为1的边 注意这里用来建边的点,是(x 阅读全文
posted @ 2018-09-13 09:27 lokiii 阅读(270) 评论(0) 推荐(0)
摘要:直接bfs,在过程中更新方案数即可 cpp include include include using namespace std; const int N=55,inf=1e9,dx[]={1,1, 1, 1,2,2, 2, 2},dy[]={2, 2,2, 2,1, 1,1, 1}; int n 阅读全文
posted @ 2018-09-01 15:57 lokiii 阅读(142) 评论(0) 推荐(0)
摘要:bfs预处理出每个点s和t的距离d1和d2(无法到达标为inf),然后在若干灌木丛格子(x,y)里取min(d1[x][y]+d2[x][y]) cpp / 0:贝茜可以通过的空地 1:由于各种原因而不可通行的区域 2:贝茜现在所在的位置 3:骑士们的位置 4:长着贝茜需要的灌木的土地 / incl 阅读全文
posted @ 2018-06-20 22:24 lokiii 阅读(142) 评论(0) 推荐(0)
摘要:A. Infinity Gauntlet 模拟就行了(不过这个题面啊……) cpp include include include include using namespace std; int n; string s[10]; maphas; mapv; int main() { has["pu 阅读全文
posted @ 2018-06-02 14:36 lokiii 阅读(172) 评论(0) 推荐(0)
摘要:直接bfs即可,注意开double,还有驱动和终点的齿轮都在序列里,要把它们找出来= = cpp include include include include using namespace std; const int N=1505; int n,sx,sy,s,t,q[N],fr[N]; bo 阅读全文
posted @ 2018-05-05 21:47 lokiii 阅读(143) 评论(0) 推荐(0)
摘要:不是严格小于是小于等于啊!!!!!不是严格小于是小于等于啊!!!!!不是严格小于是小于等于啊!!!!! 是我看不懂人话还是翻译不说人话= = 把所有格子按值排个序,bfs扩展打标记即可 cpp include include include include using namespace std; 阅读全文
posted @ 2018-05-05 16:41 lokiii 阅读(127) 评论(0) 推荐(0)
摘要:在洛谷上被卡了一个点开了O2才过= = bfs即可,为方便存储,把所有坐标+500 cpp include include include using namespace std; const int N=1005,dx[]={ 1,1,0,0},dy[]={0,0, 1,1}; int n,sx, 阅读全文
posted @ 2018-05-03 20:13 lokiii 阅读(151) 评论(0) 推荐(0)
摘要:满脑子dp简直魔性 模拟题意bfs转移即可 阅读全文
posted @ 2018-04-30 20:52 lokiii 阅读(132) 评论(0) 推荐(0)
摘要:模拟就行……讲道理这个时间复杂度为啥是对的??? cpp include include using namespace std; int k,n; int dfs(int v) { if(v 阅读全文
posted @ 2018-04-27 16:57 lokiii 阅读(159) 评论(0) 推荐(0)
摘要:t记录每个格子最早被砸的时间,bfs(x,y,t)表示当前状态为(x,y)格子,时间为t。因为bfs,所以先搜到的t一定小于后搜到的,所以一个格子搜一次就行 cpp include include include using namespace std; const int N=505,inf=1e 阅读全文
posted @ 2018-04-27 15:36 lokiii 阅读(139) 评论(0) 推荐(0)
摘要:参考论文:https://wenku.baidu.com/view/6f9f2223dd36a32d73758126.html 参考代码:http://hzwer.com/3500.html ~~虽然会写了但是我还是不知道弦图是个什么玩意~~ 阅读全文
posted @ 2018-03-03 21:53 lokiii 阅读(203) 评论(0) 推荐(0)