![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
DFS BFS
文章平均质量分 69
记录ACM 搜索(dfs bfs)问题
PushyTao
这个作者很懒,什么都没留下…
展开
-
ECNA 2013 部分题解 | 训练记录
0706 ECNA 2013 训练记录原创 2022-07-08 00:43:46 · 804 阅读 · 1 评论 -
[leetcode] 2039. 网络空闲的时刻 | BFS
题目链接题意:给定一张n个点不含重边的无向图,点的编号从0开始到n-1,两点之间如果有连边,可以认为耗时为1秒1->n-1的点都需要向0号点发送消息(从第0秒开始)在0号收到消息之后,会回复消息;从第一秒开始,如果1->n-1号服务器经过patiennce[]时间都还没有收到回复的消息,那么就会重新发送请求的消息问最早的网络中没有消息传输的时间是什么时候思路:最早的没有消息传输的时间为所有点空闲的时间中最晚的那个时间节点bfs设一个点u到0号点的距离为dis,并且经过t秒后原创 2022-03-20 22:56:53 · 555 阅读 · 0 评论 -
[leetcode]剑指 Offer 32 - III. 从上到下打印二叉树 III BFS二叉树
题目链接二叉树简单遍历将访问的序列存入vectorvectorvector,对于每一层交替从左向右从右向左我们可以设置一个变量flag来决定方向用preprepre表示上一层的节点数量,用cntcntcnt求得上本层的节点数量,在遍历的时候遇到一个点就将pre−1pre-1pre−1,如果说preprepre为0了,那么就说明上一层的节点已经访问完毕,然后将在该过程中访问得到valvalval的vectorvectorvector集合存入答案,根据flagflagflag的值进行判断是否需要逆置C原创 2022-03-06 18:42:41 · 110 阅读 · 0 评论 -
[Codeforces 1286B] Numbers on Tree | 技巧构造
Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer ai written on it. For each vertex i, Evlampiy calculated ci — the number of vertices j in the subtree of vertex i, such that aj&l原创 2021-11-09 21:23:31 · 176 阅读 · 0 评论 -
[CCPC 2019] 厦门 | Zayin and Obstacles | 三维差分前缀 + bfs
DescriptionRecently, Zayin became obsessed with a tower defense game called Arknights. The most special level is the 5th level of chapter 4: Don’t panic. The most special thing about this level is that an enemy will continue taking radioactive damage afte原创 2021-10-26 20:41:53 · 228 阅读 · 0 评论 -
[Nowcoder | UPC] 2021年度训练联盟热身训练赛第六场 Hopscotch | 最短路 bfs
题目描述There’s a new art installation in town, and it inspires you… to play a childish game. The art installation consists of a floor with an n×n matrix of square tiles. Each tile holds a single number from 1 to k. You want to play hopscotch on it. You want t原创 2021-09-14 15:58:03 · 188 阅读 · 0 评论 -
[Nowcoder] 2021年度训练联盟热身训练赛第六场 Mini Battleship | 深搜 回溯 乱搞
题目链接题目描述Battleship is a game played by two players. Each player has their own grid, which is hidden from their opponent. Each player secretly places some ships on their grid. Each ship covers a horizontal or vertical straight line of one or more contingu原创 2021-09-14 14:36:48 · 446 阅读 · 0 评论 -
2019牛客暑期多校2-Partition problem深搜
输入10 33 0输出3题意:将2*n个人分成两部分,每部分都有n个人而且每个人只能属于一个组,问按照给出的算式得到的竞争力最大值是多少ll n,ans = 0;ll a[40][40];int sel[40];ll sum[maxn];int r = 0;void dfs(ll curval,int pos){ if(r == n) { ans = max(ans,curval); return ; } if(pos >= 2 * n + 1 || r.原创 2021-08-13 13:02:19 · 150 阅读 · 0 评论 -
[AtCoder ARC098] Donation| 建图 | 树型dp
Donationinput1:4 53 11 24 16 21 22 32 41 43 4input2:5 86 415 1315 1915 120 71 31 41 52 32 42 53 54 5output2:44input3:9 10131 298 79242 32231 38382 82224 22140 88209 70164 646 81 61 41 34 74 93 73 95 9原创 2021-08-10 20:05:32 · 120 阅读 · 0 评论 -
2021-杭电-4-持久更新记录
A . CalculusSamplesInput21sinx+0cosx+3x+6/sinx0OutputNOYES因为给出的级数都是发散的,所以说只需要判断系数是不是都是0就好了只有所有都是0的时候才是可以的int main() { string s; int _ = read; while(_ --){ cin >> s; int len = s.size(),flag = 0; for(int i=0;i<len;i++) if(isdi原创 2021-07-31 12:21:50 · 117 阅读 · 2 评论 -
Biggest Number深搜
DescriptionYou have a maze with obstacles and non-zero digits in it:You can start from any square, walk in the maze, and finally stop at some square. Each step, you may only walk into one of the four neighbouring squares (up, down, left, right) and you原创 2021-07-19 20:20:16 · 243 阅读 · 2 评论 -
PTA | 喊山 (30 分) BFS 拼题A
喊山,是人双手围在嘴边成喇叭状,对着远方高山发出“喂—喂喂—喂喂喂……”的呼唤。呼唤声通过空气的传递,回荡于深谷之间,传送到人们耳中,发出约定俗成的“讯号”,达到声讯传递交流的目的。原来它是彝族先民用来求援呼救的“讯号”,慢慢地人们在生活实践中发现了它的实用价值,便把它作为一种交流工具世代传袭使用。(图文摘自:http://news.xrxxw.com/newsshow-8018.html)一个山头呼喊的声音可以被临近的山头同时听到。题目假设每个山头最多有两个能听到它的临近山头。给定任意一个发出原.原创 2021-04-15 18:46:21 · 613 阅读 · 2 评论 -
黑白棋_lduoj_dfs深搜
DescriptionLagno是一种二人智力游戏。游戏设有一个黑方和一个白方。游戏桌面是正方形的,包含8行8列。如果黑方玩家走出这样一步棋:将一枚黑子放在任一空格上,而在这个空格的八个方向(上、下、左、右和4个对角线方向)的至少一个方向上有一排白子被夹在这枚新下的黑子和其他黑子之间,任何方向,在新黑子和原来黑子之间的所有白子都要变成黑子。为这个游戏设计一个程序,计算一步棋中黑方能转变的白子数量的最大值。Input输入文件lango.in共8行,每行8个字符;“.”代表一个空格;“B”代表黑子,“W原创 2021-02-25 23:39:01 · 318 阅读 · 2 评论 -
境界的彼方_lduoj_bfs宽搜
Descriptionwyy是一个著名动画《境界的彼方》的男主,此时他非常的慌张,因为女主栗山未来进入了境界的彼方内部,并且花费了大量的血量去拯救wyy,wyy此时也进入了境界的彼方,他妈给了他一张地图去寻找境界的彼方的核心去拯救女主,现给你一张n×n的地图,以及男主的位置,问男主要拐弯几次才会到达境界的彼方内部(境界的彼方的位置为(n,n))不过你以为这就是道搜索题?还得加条件:此时女主血条狂掉,你必须判断此时wyy是否可以走到终点且女主的血条不会掉光,如果掉光了那么输出"Die",如果地图无法到达境原创 2021-02-22 01:02:19 · 926 阅读 · 3 评论