PAT_A1134#Vertex Cover
Source:
Description:
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not.
Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N and M(both no more than 1), being the total numbers of vertices and the edges, respectively. Then Mlines follow, each describes an edge by giving the indices (from 0 to N−1) of the two ends of the edge.
After the graph, a positive integer K (≤ 100) is given, which is the number of queries. Then K lines of queries follow, each in the format:
Nv v[1] v[2]⋯v[Nv]
where Nv is the number of vertices in the set, and ['s are the indices of the vertices.
Output Specification:
For each query, print in a line
Yes
if the set is a vertex cover, orNo
if not.
Sample Input:
10 11
8 7
6 8
4 5
8 4
8 1
1 2
1 4
9 8
9 1
1 0
2 4
5
4 0 3 8 4
6 6 1 7 5 4 9
3 1 8 4
2 2 8
7 9 8 7 6 5 4 2
Sample Output:
No
Yes
Yes
No
No
Keys:
Attention:
- vis[n]设为哨兵,少声明一个变量-,-
Code:
/*
Data: 2019-05-29 19:57:25
Problem: PAT_A1134#Vertex Cover
AC: 19:55 题目大意:
若集合中各顶点的边的集合 = 整个图的边集,称该顶点集为VC集;
判断所给顶点集合是否为VC集
输入:
第一行给出,顶点数N和边数M,均<=1e4
接下来M行,给出顶点对
接下来一行,给出测试数K<=100
接下来K行,首先给出顶点数N,接下来N个数表示N个顶点 基本思路:
遍历各条边,若存在一条边的两个顶点均不在集合中,则非VC集
*/ #include<cstdio>
#include<algorithm>
const int M=1e4+;
using namespace std;
struct node
{
int v1,v2;
}adj[M];
int vis[M]; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int n,m,k,v,v1,v2;
scanf("%d%d", &n,&m);
for(int i=; i<m; i++)
{
scanf("%d%d", &v1,&v2);
adj[i].v1=v1;
adj[i].v2=v2;
}
scanf("%d", &k);
while(k--)
{
scanf("%d", &v);
fill(vis,vis+M,);
for(int i=; i<v; i++){
scanf("%d", &v1);
vis[v1]=;
}
for(int i=; i<m; i++){
if(vis[adj[i].v1]== && vis[adj[i].v2]==){
vis[n]=;break;
}
}
if(vis[n]) printf("No\n");
else printf("Yes\n");
} return ;
}
PAT_A1134#Vertex Cover的更多相关文章
- 集合覆盖 顶点覆盖: set cover和vertex cover
这里将讲解一下npc问题中set cover和vertex cover分别是什么. set cover: 问题定义: 实例:现在有一个集合A,其中包含了m个元素(注意,集合是无序的,并且包含的元素也是 ...
- URAL 2038 Minimum Vertex Cover
2038. Minimum Vertex Cover Time limit: 1.0 secondMemory limit: 64 MB A vertex cover of a graph is a ...
- PAT1134:Vertex Cover
1134. Vertex Cover (25) 时间限制 600 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A vertex ...
- A1134. Vertex Cover
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at le ...
- PAT A1134 Vertex Cover (25 分)——图遍历
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at le ...
- PAT 甲级 1134 Vertex Cover
https://pintia.cn/problem-sets/994805342720868352/problems/994805346428633088 A vertex cover of a gr ...
- 二分图匹配 + 最小点覆盖 - Vertex Cover
Vertex Cover Problem's Link Mean: 给你一个无向图,让你给图中的结点染色,使得:每条边的两个顶点至少有一个顶点被染色.求最少的染色顶点数. analyse: 裸的最小点 ...
- SCU - 4439 Vertex Cover (图的最小点覆盖集)
Vertex Cover frog has a graph with \(n\) vertices \(v(1), v(2), \dots, v(n)\) and \(m\) edges \((v(a ...
- 四川第七届 D Vertex Cover(二分图最小点覆盖,二分匹配模板)
Vertex Cover frog has a graph with nn vertices v(1),v(2),…,v(n)v(1),v(2),…,v(n) and mm edges (v(a1), ...
随机推荐
- 为什么要阅读——兼分享《首先,打破一切常规》[中译文]:世界顶级管理者的成功秘诀/(美)马库斯·白金汉,(美)柯特·科夫曼 著
<ctrlno=255632">首先,打破一切常规>[中译文]:世界顶级管理者的成功秘诀/(美)马库斯·白金汉,(美)柯特·科夫曼 著:鲍世修 等译 下载地址:http:/ ...
- .NET几大热点问题(.NET人员必读)
下面收集了关于.NET几大热点问题及简要答案,防止我们回答问题不专业的尴尬.同一时候还将一些.NET资源的相关网址罗列一二. 一.什么是.Net?它主要包含什么? .Net是为简化在第三代因特网的高 ...
- ASP.NET—016:ASP.NET中保存文件对话框
本想在asp.net中使用savediallog保存文件,结果提示:当应用程序不是以 UserInteractive 模式执行时显示模式对话框或窗口是无效操作. 在ASP.NET中使用例如以下方式.保 ...
- Java判断是否为移动端
以下为常用判断,可直接创建使用 /** * Created by kangao on 2018/3/23. */public class UAgentInfoHelper { // User-Agen ...
- pytest 失败用例重试
https://www.cnblogs.com/jinzhuduoduo/articles/7017405.html http://www.lxway.com/445949491.htm https: ...
- Git是什么?
Git是目前世界上最先进的分布式版本控制系统(没有之一). Git有什么特点?简单来说就是:高端大气上档次! 那什么是版本控制系统? 如果你用Microsoft Word写过长篇大论,那你一定有这样的 ...
- C++ this指针 全部
在每一个成员函数中都包含一个特殊的指针,这个指针的名字是固定的.叫做this.它是指向本类对象的指针,它的值是当前被调用的成员函数所在的对象的起 始地址.例如:当调用成员函数a.volume ...
- 联想Thinkpad L460安装Win7 64位
单位发了L460,自带的系统为win10,但是涉及到很多工作以及客户都是在win7环境下,所以必须安装win7的系统,经过一番折腾,终于装好了. 主要顺序如下: 1,制作WINPE启动盘,如大白菜,老 ...
- css 继承性和层叠性
css有两大特性:继承性和层叠性 继承性 面向对象语言都会存在继承的概念,在面向对象语言中,继承的特点:继承了父类的属性和方法.那么我们现在主要研究css,css就是在设置属性的.不会牵扯到方法的层面 ...
- vue中的config配置
在webpack.base.conf文件中配置别名以及扩展名 resolve: { extensions: ['.js', '.vue', '.json', '.styl'], alias: { 'v ...