标签:定义 func rect positive param test sample contain tput
The “Hamilton cycle problem” is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a “Hamiltonian cycle”.
In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle.
Each input file contains one test case. For each case, the first line contains 2 positive integers N (2<N≤200), the number of vertices, and M, the number of edges in an undirected graph. Then M lines follow, each describes an edge in the format Vertex1 Vertex2
, where the vertices are numbered from 1 to N. The next line gives a positive integer K which is the number of queries, followed by K lines of queries, each in the format:
n V1 V2 … V**n
where n is the number of vertices in the list, and V**i‘s are the vertices on a path.
For each query, print in a line YES
if the path does form a Hamiltonian cycle, or NO
if not.
1 | 6 10 |
1 | YES |
作者: CHEN, Yue
单位: 浙江大学
时间限制: 300 ms
内存限制: 64 MB
代码长度限制: 16 KB
给出一个图,要求判断一个环是否是Hamiltonian cycle。题目对这个定义说得挺不清楚的。其实就是必须是简单环(除起点终点不能重复)而且图中所有点都要访问一次。
1 |
|
标签:定义 func rect positive param test sample contain tput
原文地址:https://www.cnblogs.com/lijianming180/p/12041482.html