BFS
文章平均质量分 84
i-unique
擅长各种姿势划水
展开
-
POJ 1383 Labyrinth(两次bfs求最长路径)
The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them either filled by rock, or free. There is also a little hook on the floor in the center of every free block. The ACM原创 2017-08-15 19:29:53 · 1000 阅读 · 1 评论 -
Ural 1033 Labyrinth(bfs)
Administration of the labyrinth has decided to start a new season with new wallpapers. For this purpose they need a program to calculate the surface area of the walls inside the labyrinth. This job is just for you!The labyrinth is represented by a matrix原创 2017-12-24 20:11:11 · 308 阅读 · 0 评论 -
URAL 1056 Computer Net (图论+bfs)
Computer net is created by consecutive computer plug-up to one that has already been connected to the net. Each new computer gets an ordinal number, but the protocol contains the number of its parent computer in the net. Thus, protocol consists of several原创 2017-12-03 22:35:14 · 315 阅读 · 0 评论 -
CodeForces 242C King's Path(bfs+stl)
The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 109 from left to原创 2017-10-15 20:29:30 · 578 阅读 · 0 评论 -
hdu 5546 Ancient Go(bfs+模拟)
Yu Zhou likes to play Go with Su Lu. From the historical research, we found that there are much difference on the rules between ancient go and modern go. Here is the rules for ancient go they were playing: ⋅⋅The game is played on a 8×88×8 cell board, t原创 2017-09-19 21:12:58 · 563 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 J. Minimum Distance in a Star Graph(bfs+状态保存)
In this problem, we will define a graph called star graph, and the question is to find the minimum distance between two given nodes in the star graph.Given an integer nn, an n-dimensionaln−dimensional star graph, also referred to as S_{n}Sn , is an原创 2017-09-24 17:03:01 · 957 阅读 · 0 评论 -
HDU 4775 Infinite Go(暴力模拟+BFS)
Go is a proverbial board game originated in China. It has been proved to be the most difficult board game in the world. “The rules of Go are so elegant, organic, and rigorously logical that if intelligent life forms exist elsewhere in the universe, they al原创 2017-08-29 20:07:06 · 600 阅读 · 0 评论 -
POJ 1753 Flip Game(bfs+状态压缩+位运算)
Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces,原创 2017-08-22 19:33:45 · 394 阅读 · 0 评论 -
POJ 2046 Gap(bfs+状态压缩+map)
Let's play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card. First, you shu2e the cards and lay t原创 2017-08-24 19:03:39 · 445 阅读 · 0 评论 -
HDU 1026 Ignatius and the Princess I (bfs+手写队列保存路径)
The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth. To make the problem simply, we assume the labyrinth is a N*M two-dimensional原创 2017-07-01 18:34:13 · 315 阅读 · 0 评论 -
HDU 1728 逃离迷宫 (bfs+一条路走到底思想)
给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去。令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中,不能转太多弯了,否则她会晕倒的。我们假定给定的两个位置都是空地,初始时,gloria所面向的方向未定,她可以选择4个方向的任何一个出发,而不算成一次转弯。gl原创 2017-07-01 18:52:37 · 375 阅读 · 0 评论 -
WUST 1482 find clouds(bfs+状态压缩)
公主生气了,现在wh需要集齐 X 种云(帽子云,波浪云。。。)让公主开心。开始wh在一个迷宫的入口处,迷宫里恰好有 X 种云,每种云恰好只有一个。wh每一步可以向上,向下,向左,向右走一步。请帮助wh计算最少需要走多少步收集到所有的云朵。由于wh有特殊 的技能,所以不用考虑wh该怎么走出去~原创 2017-07-06 11:30:57 · 330 阅读 · 0 评论 -
WUST 1627 打怪游戏(优先队列+bfs)
一颗树有n个节点(编号从0到n-1),树上每一个节点可能有多只怪物。 小明在0号节点,他想要清除这棵树上所有的怪物。他现在有atk大小的攻击力。只有当他的攻击力大于怪物的防御力时,他才可以打败该怪物。每打败一只怪物,还会增加一定的攻击力。一个节点可能存在着不止一只怪兽,你要打败这个节点的所有怪物才能可以从这个节点通过,请问他能不能完成这个任务?注意:不要求一次性杀光一个节点里面的所有怪物。原创 2017-07-09 20:22:44 · 439 阅读 · 0 评论 -
WUST 2050 三维迷宫(bfs)
你现在处于一栋楼里的'S'的起始位置,'#'是墙壁,'.'是路,'E'是重点,'U'的楼梯代表你可以上去一层,'D'的楼梯代表你可以下去一层(保证上去跟下去的地方不会是墙壁)。请你告诉我至少要多少步才能到达终点,当然有可能去不到重点,这时请输出"Trapped!"原创 2017-07-24 15:38:10 · 452 阅读 · 0 评论 -
HDU 4109 Instrction Arrangement(拓扑排序+bfs)
Ali has taken the Computer Organization and Architecture course this term. He learned that there may be dependence between instructions, like WAR (write after read), WAW, RAW. If the distance between two instructions is less than the Safe Distance, it wil原创 2017-07-31 20:53:24 · 520 阅读 · 0 评论 -
POJ 3626 Mud Puddles(bfs)
Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the previous evening saw a heavy rain, and the fields are quite muddy. FJ starts at the point (0, 0) in the coordinate plane and heads toward Bessie who is located原创 2017-08-01 15:54:21 · 331 阅读 · 0 评论 -
HDU 2444 The Accomodation of Students (二分图匹配+匈牙利算法+bfs判断是否为二分图)
There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other.But this may not imply that A and C know each other. Now you are given all pairs of students who know each ot原创 2017-08-07 19:49:17 · 337 阅读 · 0 评论 -
Codeforces 196 B. Infinite Maze(bfs)
We've got a rectangular n × m-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze and cyclically tiled a plane with it so that the plane became an infinite原创 2018-01-04 21:58:52 · 526 阅读 · 0 评论