shyyhs
shyyhs
全部文章
题解
DP专题(52)
图论(4)
多校补题(2)
数据结构(27)
数论(4)
日记(14)
未归档(38)
归档
标签
去牛客网
登录
/
注册
shyyhs的博客
全部文章
/ 题解
(共16篇)
maze
来自专栏
前言: 喷死这题,lj死了.出口也有陷阱,大家要小心哦! 思路: 直接bfs+优先队列就好了. 代码: #include <bits/stdc++.h> using namespace std; const int N=3e2+5; struct xb{ int x,y; }st...
BFS
优先队列
2021-01-13
12
1166
Text Editor
来自专栏
记得开文件就好= - = #include <bits/stdc++.h> using namespace std; const int N=1e2+5,M=1e5+5; int c[N][M]; int a[N]; int w[N][M]; int dis[N][M]; int vis...
BFS
2020-09-10
0
618
Igor and his way to work
来自专栏
为什么每次跟自己说,小心点数据范围= - =却总是不尽人意...这题是个bfs的好题(因为跟以前的bfs有很大的不同)因为限制是2所以直接做两次bfs即可,第一次拿起点做,把可以拐一次就到的点更新,第二次拿可以拐一次就到的点做bfs,再拐一次,把拐两次可以到的点更新,最后判断更新了终点没有,更新了就...
BFS
2020-09-09
0
647
Subway
来自专栏
dfs找环的那个代码写的很烂= - =思路挺简单的,你找到环然后bfs一下就完事了 #include <bits/stdc++.h> using namespace std; const int N=3e3+5; vector<int>v[N]; vector<int&...
DFS
BFS
2020-09-09
0
528
Fight Against Traffic
来自专栏
建个图,跑两个bfs算下距离,假如不是因为这条边的产生使得距离变短了,就ans++.n^2枚举添加的边.代码如下: #include <bits/stdc++.h> using namespace std; const int N=1e3+5; vector<int>v[N]...
BFS
2020-09-08
0
635
Mike and Shortcuts
来自专栏
建图跑个bfs就好了= - = #include <bits/stdc++.h> using namespace std; const int N=2e5+5; vector<int>v[N]; int vis[N],dis[N]; queue<int>q; vo...
BFS
2020-09-08
0
624
Fair
来自专栏
一个题目数据小就是那个题目的突破点(一般),比如这个题目,大家貌似都能想到n^2的,但是大家看一眼k的大小会发现,这题的突破点在k(这题不是水题= - =).考虑对于没种颜色做一次bfs,算出其他点到这种颜色的最短距离.代码如下: #include <bits/stdc++.h> usi...
BFS
2020-09-08
0
507
Spanning Tree with Maximum Degree
来自专栏
#include <bits/stdc++.h> using namespace std; const int N=2e5+5; struct vv{ int from,to; }; int vis[N];//不能走到重复点. vector<int>v[N]; vec...
BFS
2020-09-07
2
599
磁力块
来自专栏
重点是bfs,分块只是优化bfs. #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N=2e5+6e4; const ll M=500;//块的大小 struct vv{ l...
分块
BFS
2020-07-22
2
793
立体推箱子2--距离***搜索还有四题
来自专栏
闲谈:这个题目该怎么写呢?我们很容易知道2次使得横坐标移动3格/纵坐标移动3格为最佳对吧.我们首先分析下小的格子,先从1-1开始?那就只有一组解对吧,2-2也是一样的吧,都是只有在终点的地方有解对吧.3-3呢?合法位子必定有解.哈哈哈,看错题目了,题目说是无限空间,那么思路还是一样的啦,那么题目就成...
BFS
2020-06-09
2
730
首页
上一页
1
2
下一页
末页