![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索(BFS,DFS)
Dust_Heart
这个作者很懒,什么都没留下…
展开
-
HDU 5909 Tree Cutting 【树型DP】
HDU 5909 Tree Cutting 【树型DP】Byteasar has a tree T with n vertices conveniently labeledwith 1,2,...,n. Each vertex of the tree hasan integer value vi.The value of a non-empty tree T is equal to v1⊕v2⊕...⊕vn, where ⊕denotes bitwise-xor.Now for every integ原创 2018-04-18 16:08:30 · 254 阅读 · 0 评论 -
2017 Multi-University Training Contest 1 && HDOJ 6035 Colorful Tree 【搜索】
2017 Multi-University Training Contest 1 && HDOJ 6035 Colorful Tree 【搜索】 There is a tree with nnodes, each of which has a type of color represented by an integer, where the color of node iis ci.The path between each two different nodes is unique,原创 2017-07-26 19:52:17 · 325 阅读 · 0 评论 -
Codeforces 466E - Information Graph 【DFS+并查集+预处理】
Codeforces 466E - Information Graph 【DFS+并查集+预处理】 There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the foll原创 2017-08-02 17:05:47 · 523 阅读 · 0 评论 -
51nod 1737 配对 && Codeforces 700B Connecting Universities【树的重心】
51nod 1737 配对 && Codeforces 700B Connecting Universities【树的重心】给出一棵n个点的树,将这n个点两两配对,求所有可行的方案中配对两点间的距离的总和最大为多少。Treeland is acountry in which there are n towns connectedby n - 1 two-way roadsuch that it's possible to get from any town to any other town. In原创 2017-07-20 21:04:05 · 374 阅读 · 0 评论 -
Codeforces 734E Anton and Tree【并查集缩点||DFS缩点+树的直径】
E. Anton and TreeAnton is growinga tree in his garden. In case you forgot, the tree is a connected acyclicundirected graph.There aren vertices in the tree, each of them is painted black or white. Antondoesn't like multicolored trees, so he wants to chang原创 2017-07-20 17:44:48 · 520 阅读 · 0 评论 -
Educational Codeforces Round 22 C The Tag Game(树的深度)
Educational Codeforces Round 22 C The Tag Game(树的深度)Alice got tired of playing the tag game by the usual rules soshe offered Bob a little modification to it. Now the game should be played onan undirected rooted tree of n vertices. Vertex 1 is the root of原创 2017-07-07 22:33:16 · 383 阅读 · 0 评论 -
HDOJ 3468 Treasure Hunting (BFS+DFS+匈牙利算法) 综合性好题,好题!!!
HDOJ 3468 Treasure Hunting (BFS+DFS+匈牙利算法) 综合性好题Do you liketreasure hunting? Today, with one of his friend, iSea is on a venture tripagain. As most movie said, they find so many gold hiding in their trip.Now iSea’s clever friend has already got the map o原创 2017-07-06 10:59:22 · 447 阅读 · 0 评论 -
FZUOJ 2250 不可能弹幕结界【BFS】
FZUOJ 2250 不可能弹幕结界【BFS】 咲夜需要穿过一片弹幕区,由于咲夜发动了符卡“The World”,所以弹幕是静止的。这片弹幕区以一个n*m的矩阵的形式给出。‘.’表示这个位置是安全的,’x’表示这个位置上是有子弹的,禁止通行。咲夜每次能向左、右、下三个方向的相邻格子走,但是不能向上走。 同时由于时间有限,咲夜在进入每一行之后最多只能横向走k步。你可以简单地认为我们的目标就是从第0行走到第n+1行,起点和终点可以是在第0行和第n+1行的任意位置,当然第0行和第n+1行都是没有弹幕的。然而原创 2017-07-15 00:09:35 · 500 阅读 · 0 评论 -
Codeforces 327D Block Tower【BFS+优先队列】
Codeforces 327D Block Tower【BFS+优先队列】 After too muchplaying on paper, Iahub has switched to computer games. The game he plays iscalled "Block Towers". It is played in a rectangular grid with n rows and m columns (itcontains n × m cells). The goal of the g原创 2017-07-06 00:34:43 · 427 阅读 · 0 评论 -
CF Round #413( Div.1/2) Field expansion
D. Field expansiontime limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard outputIn one of the games Arkady is fond ofthe game process h原创 2017-05-12 15:17:10 · 507 阅读 · 0 评论 -
HDOJ 2489 Minimal Ratio Tree (Kruskal+Dfs)
Minimal Ratio TreeTimeLimit: 2000/1000 MS (Java/Others) Memory Limit:32768/32768 K (Java/Others)Total Submission(s): 4294 Accepted Submission(s): 1360Problem DescriptionFor a tree,wh原创 2017-05-22 23:34:47 · 330 阅读 · 0 评论 -
2017 Multi-University Training Contest 6 && HDOJ 6105 Gameia 【树形博弈】
2017 Multi-University Training Contest 6 && HDOJ 6105 Gameia 【树形博弈】 Alice and Bob are playing a game called 'Gameia ? Gameia !'. The game goes like this :0. There is a tree with all node unpainted initial.1. Because Bob is the VIP player, so Bob has K c原创 2017-08-10 20:20:48 · 592 阅读 · 2 评论 -
HDU 5692 Snacks 【DFS序+线段树】
SnacksTime Limit: 10000/5000 MS (Java/Others) Memory Limit:65536/65536 K (Java/Others)Total Submission(s): 3282 Accepted Submission(s): 762Problem Description百度科技园内有n个零食机,零食机之间通过n−1条路相互连通。每个零食机都...原创 2017-08-12 10:52:36 · 425 阅读 · 0 评论 -
Codeforces 937D - Sleepy Game 【博弈+判环】
Codeforces 937D - Sleepy Game 【博弈+判环】Petya and Vasyaarranged a game. The game runs by the following rules. Players have a directedgraph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is locatedat vertex s. Pl原创 2018-03-23 11:52:31 · 328 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第四场) A 石油采集 【二分匹配+DFS】
2018年全国多校算法寒假训练营练习比赛(第四场) A 石油采集 【二分匹配+DFS】随着海上运输石油泄漏的问题,一个新的有利可图的行业正在诞生,那就是撇油行业。如今,在墨西哥湾漂浮的大量石油,吸引了许多商人的目光。这些商人们有一种特殊的飞机,可以一瓢略过整个海面20米乘10米这么大的长方形。(上下相邻或者左右相邻的格子,不能斜着来)当然,这要求一瓢撇过去的全部是油,如果一瓢里面有油有水的话,那就毫无意义了,资源完全无法利用。现在,商人想要知道,在这片区域中,他可以最多得到多少瓢油。地图是一个N×N的网原创 2018-02-11 22:53:42 · 398 阅读 · 0 评论 -
Codeforces 591E - Three States 【BFS】
Codeforces 591E - Three States 【BFS】 The famous global economic crisis is approaching rapidly, so thestates of Berman, Berance and Bertaly formed an alliance and allowed theresidents of all member states to freely pass through the territory of any ofthem.原创 2017-11-22 00:45:10 · 349 阅读 · 0 评论 -
HDU 6228/2017ACM/ICPC 沈阳 Tree 【DFS】
HDU 6228/2017ACM/ICPC 沈阳 Tree 【DFS】Consider a un-rooted tree T which is not the biological significance of tree or plant,but a tree as an undirected graph in graph theory with n nodes, labelled from 1to n. If you cannot understand the concept of a tree he原创 2017-11-05 13:30:59 · 2272 阅读 · 0 评论 -
Codeforces 877D - Olya and Energy Drinks 【简单BFS变形】
Olya loves energy drinks. She loves them so much that her roomis full of empty cans from energy drinks.Formally, her room can be represented as a field of n × m cells, each cell of which is empty or littered with cans.Olya drank a lot of energy drink, so原创 2017-10-24 21:09:41 · 1826 阅读 · 0 评论 -
HDOJ 5094 Maze 【状态压缩+BFS】
HDOJ 5094 Maze 【状态压缩+BFS】This story happened on the background of Star Trek.Spock, the deputy captain of Starship Enterprise, fell into Klingon’s trick andwas held as prisoner on their mother planet Qo’noS.The captain of Enterprise, James T. Kirk, had原创 2017-07-24 20:21:50 · 341 阅读 · 0 评论 -
Codeforces 676D - Theseus and labyrinth 【BFS(二进制优化迷宫旋转)】
Codeforces 676D - Theseus and labyrinth 【BFS(二进制优化迷宫旋转)】 Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of size n × m and consists of blocks of size 1 × 1.Each block of the labyrinth has a原创 2017-07-30 18:12:24 · 498 阅读 · 0 评论 -
HDU 6201 transaction transaction transaction【树形DP||SPFA最长路】
transactiontransaction transactionTime Limit: 4000/2000 MS(Java/Others)Memory Limit: 132768/132768 K(Java/Others)Total Submission(s): 38Accepted Submission(s): 21Problem Description...原创 2017-09-10 18:45:25 · 1476 阅读 · 0 评论 -
Codeforces 842C - Ilya And The Tree 【树上DFS】
Codeforces 842C - Ilya And The Tree 【树上DFS】 Ilya is very fond of graphs, especially trees. During his lasttrip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written oneach vertex of the tree; the number w原创 2017-08-30 09:26:32 · 1629 阅读 · 4 评论 -
HDU 5527 Too Rich 【DFS】
HDU 5527 Too Rich 【DFS】2015ACM/ICPC亚洲区长春站-重现赛(感谢东北师大) You are a rich person, and you think your wallet is too heavy and full now. So youwant to give me some money by buying a lovely pusheen sticker which costs p dollars fromme. To make your wallet lighte原创 2017-09-13 13:55:32 · 466 阅读 · 0 评论 -
HDOJ 2579 Dating with girls(2) (BFS)
Dating with girls(2)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3624 Accepted Submission(s): 1059Problem DescriptionIf you原创 2017-04-03 01:13:28 · 255 阅读 · 0 评论 -
HDOJ 1072 Nightmare (DFS)
NightmareTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11155 Accepted Submission(s): 5429Problem DescriptionIgnatius had a ni原创 2017-04-03 00:10:06 · 252 阅读 · 0 评论 -
HDOJ 1175 连连看(DFS)
连连看Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34452 Accepted Submission(s): 8556Problem Description“连连看”相信很多人都玩过。没玩过也没关系原创 2017-04-03 00:12:58 · 264 阅读 · 0 评论 -
HDOJ 1728 逃离迷宫 (DFS)
逃离迷宫Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 26002 Accepted Submission(s): 6319Problem Description 给定一个m × n (m行, n列)的迷原创 2017-04-03 00:08:04 · 409 阅读 · 0 评论 -
HDOJ 1026 Ignatius and the Princess I (BFS + 优先队列 + 输出路径)
Ignatius and the Princess ITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18690 Accepted Submission(s): 6034Special JudgeProblem原创 2017-04-03 01:09:11 · 209 阅读 · 0 评论 -
HDOJ 2616 Kill the monster(DFS+BFS)
Kill the monsterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1510 Accepted Submission(s): 1030Problem DescriptionThere is a原创 2017-04-03 00:30:50 · 271 阅读 · 0 评论 -
HDOJ 1254 推箱子 (双BFS)
推箱子Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8231 Accepted Submission(s): 2377Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版原创 2017-04-03 00:55:51 · 343 阅读 · 0 评论 -
HDOJ 1429 胜利大逃亡(续) (BFS + 状态压缩)
胜利大逃亡(续)Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8413 Accepted Submission(s): 3019Problem DescriptionIgnatius再次被魔王抓走了(搞不原创 2017-04-03 00:53:59 · 323 阅读 · 0 评论 -
HDOJ 1495 非常可乐 (BFS 模拟)
非常可乐Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13809 Accepted Submission(s): 5499Problem Description大家一定觉的运动以后喝可乐是一件很惬意的事情原创 2017-04-03 00:48:01 · 246 阅读 · 0 评论 -
HDOJ 1242 Rescue (BFS)
RescueTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29544 Accepted Submission(s): 10405Problem DescriptionAngel was caught by原创 2017-04-03 00:44:44 · 246 阅读 · 0 评论 -
HDOJ 1180 诡异的楼梯 (BFS)
诡异的楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 14368 Accepted Submission(s): 3662Problem DescriptionHogwarts正式开学以后,Harry原创 2017-04-03 00:42:46 · 299 阅读 · 0 评论 -
HDOJ 4284 Travel (DFS + Floyd )
TravelTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4338 Accepted Submission(s): 1165Problem Description PP loves travel. H原创 2017-04-03 00:39:30 · 281 阅读 · 0 评论 -
马踏棋盘
对于一个N*N的棋盘,问可以使马遍历棋盘上所有点的方案数,并输出方案#include int s,cnt=0;int vis[100][100];void print(){ int i,j; printf("case #%d:\n",++cnt); for(i=0; i<s; i++) { for(j=0; j<s-1; j++)原创 2017-01-17 21:10:00 · 480 阅读 · 0 评论