Vertex Coloring

PAT-1154

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<unordered_map>
using namespace std;
const int maxn=10004;
int n,m;
vector<int>ve[maxn];
int colo[maxn];
int main(){
cin>>n>>m;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
ve[a].push_back(b);
ve[b].push_back(a);
}
int k;
cin>>k;
while(k--){
set<int>se;
for(int j=0;j<n;j++){
cin>>colo[j];
se.insert(colo[j]);
}
int numk=0;
bool flag=true;
for(int j=0;j<n;j++){
int acolor=colo[j];
for(auto item:ve[j]){
int b=item;
int bcolor=colo[b];
if(bcolor==acolor){
flag=false;
break;
}
}
if(!flag)
break;
}
if(flag){
cout<<se.size()<<"-coloring"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}

PAT-1154(Vertex Coloring )+map使用+vector建图+set的使用的更多相关文章

  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. 1154 Vertex Coloring

    题目前半略 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 ...

  7. 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 ...

  8. Dijkstra算法堆优化(vector建图)

    #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> ...

  9. zzulioj--1831-- 周末出游(vector建图+dfs)

    1831: 周末出游 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 22  Solved: 8 SubmitStatusWeb Board Descr ...

随机推荐

  1. 悬线法——有套路的DP

    例题 P1169 [ZJOI2007]棋盘制作 题目描述 国际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源于易经的思想,棋盘是一个8×88 \times ...

  2. L3-002 特殊堆栈 (30分) vector容器的模拟、vector容器的一些用法

    vector容器的简单应用,我们可以用vector维护一个有序数组,每次对要插入的数用upper_bound或者lower_bound来 为这个数找一个应该插入到vector的位置.另外再找一个数组来 ...

  3. Linux系统编程【3.1】——编写ls命令

    ls命令简介 老规矩,直接在终端输入:man ls (有关于man命令的简介可以参考笔者前期博客:Linux系统编程[1]--编写more命令) 可以看到,ls命令的作用是显示目录中的文件名,它带有可 ...

  4. .net core面试题

    第1题,什么是ASP net core? 首先ASP net core不是 asp net的升级版本.它遵循了dot net的标准架构, 可以运行于多个操作系统上.它更快,更容易配置,更加模块化,可扩 ...

  5. Python小练习批量爬取下载歌曲

    import requests import os headers={ 'Cookie': '_ga=GA1.2.701818100.1612092981; _gid=GA1.2.748589379. ...

  6. 二进制安装kubernetes(五) kubelet组件安装

    概述资料地址:https://blog.csdn.net/bbwangj/article/details/81904350 Kubelet组件运行在Node节点上,维持运行中的Pods以及提供kube ...

  7. iTerm2终端工具在Mac OS上使用详解

    一.概述 因个人工作需要,使用终端工具进行运维和开发工作,但是Mac OS 自带的终端工具使用堡垒机登录配置不了,而且使用CRT等终端工具每次登录堡垒机都需要配置密码,操作起来很麻烦.一直想找一款终端 ...

  8. 牛客网多校第9场 E Music Game 【思维+数学期望】

    题目:戳这里 题意:鼠标点击n下,第i次点击成功的概率为p[i],连续点击成功x次可以获得x^m分,求n次点击总分数的数学期望. 解题思路:数学期望的题很多都需要转化思维,求某一个单独状态对整体答案的 ...

  9. HEXO添加置顶功能

    使用库:参考 http://wangwlj.com/2018/01/09/blog_pin_post/ 目前已经有修改后支持置顶的仓库,可以直接用以下命令安装.(cmd 到博客根目录,nmp运行) $ ...

  10. 三、mysql主从复制

    1 MySQL 主从复制 1.1 主从复制的含义 在 MySQL 多服务器的架构中,至少要有一个主节点(master),跟主节点相对的,我们把它叫做从节点(slave). 主从复制,就是把主节点的数据 ...