当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5222:Exploration

题目描述
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.
输入解释
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 number of undirectional tunnels, the number of directional tunnels.

The next $M1$ lines contain the details of the undirectional tunnels. Each line contains two integers $u,~v$ meaning that there is a undirectional tunnel between $u,~v$. ($u~\neq~v$)

The next $M2$ lines contain the details of the directional tunnels. Each line contains integers $u,~v$ meaning that there is a directional tunnel from $u$ to $v$. ($u~\neq~v$)

$T$ is about 100.

$1~\le~N, M1, M2~\le~1000000.$

There may be some tunnels connect the same pair of caves.

The ratio of test cases with $N~\gt~1000$ is less than 5%.
输出解释
For each test queries, print the answer. If Miceren can do that, output "YES", otherwise "NO".
输入样例
2
5 2 1
1 2
1 2
4 5
4 2 2
1 2
2 3
4 3
4 1
输出样例
YES
NO

提示
If you need a larger stack size, 
please use #pragma comment(linker, "/STACK:102400000,102400000") and submit your solution using C++.
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5222

最后修改于 2020-10-25T23:20:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
30000/15000MS(Java/Others) 131072/131072K(Java/Others)