求迷宫两点最长距离

该问题描述了一种迷宫寻路挑战,要求确定在给定迷宫中两个自由区块之间的最大路径长度。迷宫由岩石(#)和空地(.)组成,确保每对空地之间存在唯一路径。解决方案可以通过两次广度优先搜索(BFS)来实现,首先找到一个起点的最长路径端点,然后从这个端点开始寻找最长路径的另一端。注意在处理多组输入时,需要正确初始化答案变量,避免错误。
摘要由CSDN通过智能技术生成

题目链接:https://vjudge.net/contest/244053#problem/J

Labyrinth

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 have found that two of the hooks must be connected by a rope that runs through the hooks in every block on the path between the connected ones. When the rope is fastened, a secret door opens. The problem is that we do not know which hooks to connect. That means also that the neccessary length of the rope is unknown. Your task is to determine the maximum length of the rope we could need for a given labyrinth.

Input

The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值