题目前半略

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. Centos7 密钥对登陆(适用于群晖DSM)

    www.swack.cn - 原文链接:Centos7 密钥对登陆(适用于群晖DSM) 1.生成证书 此处证书使用swack用户生成 注:不要使用root生成证书,因为我们后面会禁用root登陆 [s ...

  2. 【SpringBoot1.x】SpringBoot1.x 分布式

    SpringBoot1.x 分布式 分布式应用 Zookeeper&Dubbo ZooKeeper 是用于分布式应用程序的高性能协调服务.它在一个简单的界面中公开了常见的服务,例如命名,配置管 ...

  3. MVC和MVVM的差别

    MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑.数据.界面显示分离的方法组织代码 ...

  4. 浅谈JVM垃圾回收

    JVM内存区域 要想搞懂啊垃圾回收机制,首先就要知道垃圾回收主要回收的是哪些数据,这些数据主要在哪一块区域. Java8和Java8之前的相同点有很多. 都有虚拟机栈,本地方法栈,程序计数器,这三个是 ...

  5. 操作系统-1w字关于内存的总结

    内存的基本概念 什么是内存,有何作用 内存是用于存放数据的硬件.程序执行前需要先放入内存中才能被CPU处理 存储单元 内存中也有一个一个的小房间,每个小房间就是一个存储单元. 如果计算机按照 字节编址 ...

  6. Flink 中极其重要的 Time 与 Window 详细解析(深度好文,建议收藏)

    前言 Flink 是流式的.实时的 计算引擎 上面一句话就有两个概念,一个是流式,一个是实时. 流式:就是数据源源不断的流进来,也就是数据没有边界,但是我们计算的时候必须在一个有边界的范围内进行,所以 ...

  7. 转 Jmeter测试实践:文件上传接口

    Jmeter测试实践:文件上传接口   1.打开jmeter4.0,新建测试计划,添加线程组.根据实际情况配置线程属性. 2.添加HTTP请求. Basic部分修改如下: Advanced部分我做任何 ...

  8. 1.Spring的基本应用

    1.1概述 1.1.1 Spring是什么 Spring一个轻量级的框架,以IOC(控制反转)和AOP(面向切面编程)为内核,Spring在表现层提供了Spring MVC的框架整和功能,在业务逻辑层 ...

  9. Visual Studio中自定义代码段!

    Visual Studio中自定义代码段! 第一步:在编辑器中进行快捷键的输入[ctrl + shift + p] 或者 点击 查看 第一个选项就是!请看下图 第二步:选择你要配置代码段的语言, 这里 ...

  10. 小白都看得懂的Javadoc使用教程

    Javadoc是什么 官方回答: Javadoc is a tool for generating API documentation in HTML format from doc comments ...