题目前半略

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. 利用DES,C#加密,Java解密代码

    //C#加密 /// <summary> /// 进行DES加密. /// </summary> /// <param name="pToEncrypt&quo ...

  2. C语言实现九大排序算法

    C语言实现九大排序算法 直接插入排序 折半插入排序 希尔排序 冒泡排序 快速排序 直接选择排序 堆排序 归并排序 基数排序 C语言实现九大排序算法 直接插入排序 将数组分为两个部分,一个是有序部分,一 ...

  3. 【剑指 Offer】07.重建二叉树

    题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字. 示例: 前序遍历 preorder = [3,9,20,15,7] 中序遍历 ...

  4. 【C++】《C++ Primer 》第七章

    第七章 类 一.定义抽象数据类型 类背后的基本思想:数据抽象(data abstraction)和封装(encapsulation). 数据抽象是一种依赖于接口(interface)和实现(imple ...

  5. Java内存模型与线程(二)线程的实现和线程的调度

    先行先发生原则(happen-before原则) 先行先发生是指Java内存模型中定义的两项操作之间的偏序关系. 如果说A先行于B,其实就是说在发生B操作之前,操作A产生的影响能被操作B观察到,至于这 ...

  6. 【栈和队列】5、队列概述与数组队列的基本实现 - Java

    3-5 数组队列 简单记录 - bobo老师的玩转算法系列–玩转数据结构 - 栈和队列 队列Queue 队列也是一种线性结构 相比数组,队列对应的操作是数组的子集 只能从一端(队尾)添加元素,只能从另 ...

  7. postgresql中权限介绍

    postgresql权限分为实例的权限,数据库的权限,模式的权限,对象的权限,表空间的权限 实例的权限:由pg_hba.conf文件控制,控制那些用户那些IP以哪种方式连接数据库 数据库的权限:是否允 ...

  8. Doge.jpg 的背后是什么,你知道么?

    图片,是我们生活中最常见的信息载体,作为一个日常生活中无处不在的事物,我们已经很习惯静态或者动态的图片了.大家也了解静态图片主要是jpg/png格式,动态图片主要为 gif.那你有没有过一瞬间的疑惑: ...

  9. C++ STL getline()函数

    getline() C++11 <string> 函数原型 //(1) istream& getline (istream& is, string& str, ch ...

  10. ajax异步实现文件分片上传

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...