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

建议使用的浏览器:

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

4674:Trip Advisor

题目描述
There is a strange country somewhere which its transportation network was built following some weird rules: Consider the transportation network as a connected undirected graph G with N nodes and M edges(nodes indicate cities,and people can travel from cities to cities by roads connecting them),the condition that every node in G is in at most one simple cycle holds.
One day Q people of the country want to make a travel, i_th people is located at city Ui, wants to move to city Vi(Ui can be equal to Vi),and he especially loves city Pi,so he wonders if there is a path that:

1. starts at Ui;
2. ends at Vi;
3. for every pair of adjacent cities in path,there is a road connecting them.
4. visits every city at most once.
5. visits city Pi;

As a trip advisor,your task is to tell everybody whether there is a path satsifying all his requirements.
输入解释
The input contains several test cases, terminated by EOF. Most of test cases are rather small.
Each testcase contains M + Q + 2 lines. first line contains two integers N, M (1 <= N <= 100000, 1 <= M <= 150000), the number of cities and roads; next M lines each contains two integer b, e indicates that there is a bidirectional-road connecting city b and city e;next line an integer Q (1 ≤ Q ≤ 100000) indicating number of people in that country that want to make a travel, next Q lines each contains three integers Ui, Vi, Pi, denotes the query as we mentioned above.
输出解释
For each test case output Q lines, for i-th query, if there exists such path, output one line "Yes" without quotes, otherwise output one line "No" without quotes.
输入样例
6 7
1 2
1 2
3 4
2 4
5 6
5 6
4 5
5
1 6 3
1 6 4
1 2 5
2 2 2
2 2 3
输出样例
No
Yes
No
Yes
No
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

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

源链接: HDU-4674

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

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 65535/65535K(Java/Others)