HDU5222 Exploration

该问题涉及一个有向图的探索,其中包含单向和双向隧道。任务是帮助Miceren从一个起点开始,至少访问另一个洞穴,然后返回起点。必须确定这样的起点是否存在。使用并查集维护无向边的连通性,并将所有连通组件'缩点'以形成有向无环图(DAG),通过拓扑排序检查是否存在环。
摘要由CSDN通过智能技术生成

http://acm.hdu.edu.cn/showproblem.php?pid=5222

Problem Description

Miceren likes exploration and he found a huge labyrinth underground!

This labyrinth has N caves and some tunnels connecting some pairs of caves.

There are two types of tunnel, one type of them can be passed in only one direction and the other can be passed in two directions. Tunnels will collapse immediately after Miceren passing them.

Now, Miceren wants to choose a cave as his start point and visit at least one other cave, finally get back to start point.

As his friend, you must help him to determine whether a start point satisfing his request exists.

 

 

Input

The first line contains a single integer T, indicating the number of test cases.

Each test case begins with three integers N, M1, M2, indicating the number of caves, the

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值