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

建议使用的浏览器:

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

3360:Take a Walk

题目描述

A walk W in a graph G is a finite sequence

v0e1v1e2v2...vk-1ekvk

whose terms are alternately vertices and edges such that, for 1 ≤ ik, the edge ei has end vertices vi-1 and vi. If the edges e1, e2, ... , ek of the walk are distinct, then W is called a trail. A trail with v0vk is an open trail.

If v0 = vk, then W is a closed walk. A tour of G is a closed walk of G that includes every edge of G at least once.

Write a program that determines whether for a graph G:

  1. there exists an open trail that includes every edge of G, or not; and
  2. there exists a tour that includes every edge of G exactly once, or not

where graph G is undirected, has at least 2 edges, has no self-loops (i.e., edges (vi, vi)), but may contain parallel edges (i.e., 2 or more edges having the same end vertices).

输入解释

The input file consists of several test cases, each with a case number, the set of vertices in a graph, and the set of edges in the graph, as shown in the samples. Assume the vertices are single letters only.

输出解释

For each of the test cases, output "Yes" if the graph has at least one open trail that includes every edge of the graph, and "No", if not; and output "Yes" if the graph has at least one tour that includes every edge of the graph exactly once, and "No" if not.

输入样例
Case 1: { a, b, c, d, e } { (a,b), (b,c), (c,d), (d,a), (b,e), (c,e) }
Case 2: { a, b, c, d, e } { (a,b), (a,c), (b,e), (b,d), (b,c), (d,c), (d,e), (d,e), (e,c) } 
Case 3: { A, B, c, d } { (A,B), (c,d) }
输出样例
Yes No 
No Yes 
No No

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Manila 2006

源链接: POJ-3360

最后修改于 2020-10-29T06:59:38+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536