1122 Hamiltonian Cycle (25 分)
1122 Hamiltonian Cycle (25 分)
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.
Input Specification:
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.
Output Specification:
For each query, print in a line YES
if the path does form a Hamiltonian cycle, or NO
if not.
Sample Input:
1 |
6 10 |
Sample Output:
1 |
YES |
作者: CHEN, Yue
单位: 浙江大学
时间限制: 300 ms
内存限制: 64 MB
代码长度限制: 16 KB
题目大意
给出一个图,要求判断一个环是否是Hamiltonian cycle。题目对这个定义说得挺不清楚的。其实就是必须是简单环(除起点终点不能重复)而且图中所有点都要访问一次。
代码
1 |
#include <vector> |
1122 Hamiltonian Cycle (25 分)的更多相关文章
- PAT甲级 1122. Hamiltonian Cycle (25)
1122. Hamiltonian Cycle (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...
- 1122. Hamiltonian Cycle (25)
The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a gra ...
- PAT甲题题解-1122. Hamiltonian Cycle (25)-判断路径是否是哈密顿回路
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789799.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 1122 Hamiltonian Cycle (25 分)
1122 Hamiltonian Cycle (25 分) The "Hamilton cycle problem" is to find a simple cycle that ...
- PAT 1122 Hamiltonian Cycle[比较一般]
1122 Hamiltonian Cycle (25 分) The "Hamilton cycle problem" is to find a simple cycle that ...
- PAT 1122 Hamiltonian Cycle
The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a gra ...
- 1122 Hamiltonian Cycle
题意:包含图中所有结点的简单环称为汉密尔顿环.给出无向图,然后给出k个查询,问每个查询是否是汉密尔顿环. 思路:根据题目可知,我们需要判断一下几个条件:(1).首先保证给定的环相邻两结点是连通的:(2 ...
- PAT1122: Hamiltonian Cycle
1122. Hamiltonian Cycle (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...
- PAT_A1122#Hamiltonian Cycle
Source: PAT A1122 Hamiltonian Cycle (25 分) Description: The "Hamilton cycle problem" is to ...
随机推荐
- springboot cloud 网盘
boot https://pan.baidu.com/s/12SkGJNu_M-I-pjg-GxqHRw 5uga boot-cloud https://pan.baidu.com/s/1gO ...
- Java static特性
static 表示是静态的 特点是:可以用类直接访问. 属于类, 在类加载时就有 因此static方法不能访问成员的 但是成员的可以访问静态的 所有对象可以共享. 因此常常用作工具,比如Math.PI ...
- Linux中的各种文件类型
Linux中有一句话:一切皆是文件 1.普通文件( - regular file ) (1).文本文件 文件中的内容是由文本构成的,文本指的是ASCII码字符.文件里的内容本质上都是数字( ...
- 6.docker container
1. 什么是container 通过 image 创建 (copy得到的) 在 image layer (在image 层) 上 增加了一层 container layer (container 层 ...
- Python笔记_第二篇_面向过程_第二部分_3.模块的概述
这部分内容是非常重要的,分模块的基本概念和一些常用模块的使用,其实常用模块使用这部分也不是太全面,后续或者有机会再通过其他材料进行讲解. 1. 模块的概述: 目前代码比较少,写在一个文件中还体现不出什 ...
- vi几个常用的命令
1.同时打开多个文件:vi 1.txt 2.txt 3.txt 在多个文件中来回切换,命令行模式输入“:next"表示下一个,输入":previous"代表进入上一个,” ...
- OfficeidMsoViewer最新版
点击下载 OfficeidMsoViewer最新版
- 华为路由器AR1220E-S通过web页面不能登录
问题原因:由于在WEB页面配置了“远程信任主机”,但是信任主机和路由器不在一个网段,导致所有IP都不能通过WEB页面管理路由器 解决方案:通过console口直接连接路由器,删除信任主机,此次咨询了华 ...
- android打飞机游戏、MVP句子迷App、悬浮窗、RxJava+Retrofit、加载动画、定制计划App等源码
Android精选源码 微信打飞机 android进度设置加载效果源码 Android新手引导库EasyGuide MVP-好看又好用的句子迷客户端 XFloatView 一个简易的悬浮窗实现方案 a ...
- Descriptive Measures for Populations|Parameter|Statistic|standardized variable|z-score
3.4 Descriptive Measures for Populations; Use of Samples For a particular variable on a particular p ...