题目前半略

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
4
0 1 0 1 4 1 0 1 3 0
0 1 0 1 4 1 0 1 0 0
8 1 0 1 4 1 0 5 3 0
1 2 3 4 5 6 7 8 8 9
 

Sample Output:

4-coloring
No
6-coloring
No
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std; vector<int> seq[10005];
int potid[10005];
set<int> special;
int main()
{
int vnum;
int edgenum;
scanf("%d %d",&vnum,&edgenum);
for(int i=0;i<edgenum;i++)
{
int id1;
int id2;
scanf("%d %d",&id1,&id2);
seq[id1].push_back(id2);
seq[id2].push_back(id1);
}
int testnum;
scanf("%d",&testnum);
for(int i=0;i<testnum;i++)
{
fill(potid,potid+10005,0);
special.clear();
int count=0;
bool flag=false;
for(int j=0;j<vnum;j++)
{
int temp;
scanf("%d",&temp);
special.insert(temp); potid[j]=temp;
}
count=special.size();
for(int t=0;t<vnum;t++)
{
for(int x=0;x<seq[t].size();x++)
{
if(potid[seq[t][x]]==potid[t]) flag=true;
}
}
if(flag==true) printf("No");
else printf("%d-coloring",count);
if(i!=testnum-1) printf("\n"); }
}

1154 Vertex Coloring的更多相关文章

  1. PTA 1154 Vertex Coloring

    题目链接:1154 Vertex Coloring A proper vertex coloring is a labeling of the graph's vertices with colors ...

  2. PAT 甲级 1154 Vertex Coloring

    https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 A proper vertex color ...

  3. pat甲级 1154 Vertex Coloring (25 分)

    A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...

  4. PAT Advanced 1154 Vertex Coloring (25 分)

    A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...

  5. PAT Advanced 1154 Vertex Coloring (25) [set,hash]

    题目 A proper vertex coloring is a labeling of the graph's vertices with colors such that no two verti ...

  6. PAT_A1154#Vertex Coloring

    Source: PAT A 1154 Vertex Coloring (25 分) Description: A proper vertex coloring is a labeling of the ...

  7. PAT-1154(Vertex Coloring )+map使用+vector建图+set的使用

    Vertex Coloring PAT-1154 #include<iostream> #include<cstring> #include<string> #in ...

  8. PAT(甲级)2018年冬季考试

    1152 Google Recruitment 思路:判断素数 #include<bits/stdc++.h> using namespace std; const int maxn = ...

  9. PAT甲级 图 相关题_C++题解

    图 PAT (Advanced Level) Practice 用到图的存储方式,但没有用到图的算法的题目 目录 1122 Hamiltonian Cycle (25) 1126 Eulerian P ...

随机推荐

  1. 关于软件架构中的b/s

    **B/S架构 b/s只需要一个浏览器,用户就可以通过不同的网址访问不同的服务器程序. 优点:开发,安装,部署,维护简单 缺点:对硬件要求过高,用户的体验会受到影响 首先是资源分类:**可以分为静态资 ...

  2. 在Linux系统下限制指定目录的大小以及文件/文件夹数量

    背景说明 在Linux操作系统下有时需要限制一个指定文件夹的大小和文件夹内可存储的文件数量,有可能是出于安全的考量或者定制化的配置,这里我们提供了一种方案:用dd创建一个空的img镜像,进行格式化的配 ...

  3. python学习笔记 | macOS Big Sur动态壁纸食用指南

    目录 前言 爬虫篇 壁纸使用篇 后记 前言 北京时间23日凌晨1点,苹果WWDC2020大会开幕.在发布会上,苹果正式发布了新版macOS,并将其命名为"Big Sur". 相比于 ...

  4. 虚拟机linux共享文件夹

    linux共享文件夹问题 1. 初配置 2. 挂载 018.7.8 为了实现win7与VMware中linux文件夹共享很花费了一些时间,但终成正果 1. 初配置 虚拟机设置->选项->共 ...

  5. Kubernetes 开船记-脚踏两只船:用 master 服务器镜像克隆出新集群

    自从2020年2月23日 园子全站登船 之后,我们一边感叹"不上船不知道,一上船吓一跳" -- kubernetes 比 docker swarm 强大太多,一边有一个杞人忧天的担 ...

  6. yum配置文件下使用自定义变量

    yum的配置文件中,可以使用的变量,简称为yum变量: 默认的yum变量有: $releasever(Release Version),发行版的版本 $arch,CPU体系结构,通过 Python 的 ...

  7. 如何用Python中自带的Pandas和NumPy库进行数据清洗

    一.概况 1.数据清洗到底是在清洗些什么? 通常来说,你所获取到的原始数据不能直接用来分析,因为它们会有各种各样的问题,如包含无效信息,列名不规范.格式不一致,存在重复值,缺失值,异常值等..... ...

  8. 面试官问我CAS,我一点都不慌

    文章以纯面试的角度去讲解,所以有很多的细节是未铺垫的. 文章中写到的处理线程安全的思路每一项技术都可以写出一篇文章,AQS.Synchronized.Atomic...周末肝起来!下周再来给大家安排! ...

  9. 词嵌入之Word2Vec

    词嵌入要解决什么问题 在自然语言系统中,词被看作最为基本的单元,如何将词进行向量化表示是一个很基本的问题,词嵌入(word embedding)就是把词映射为低维实数域向量的技术. 下面先介绍几种词的 ...

  10. SpringBoot @Value 解析集合配置

    引自:https://jitwxs.cn/d6d760c4.html 一.前言 在日常开发中,经常会遇到需要在配置文件中,存储 List 或是 Map 这种类型的数据.Spring 原生是支持这种数据 ...