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. 【noi 2.6_6045】开餐馆(DP)

    题意:有N个地址,从中选一些开餐馆,要保证相邻餐馆的距离大于k.问最大利润. 解法:f[i]表示在前 i 个地址中选的最大利润. 1 #include<cstdio> 2 #include ...

  2. MiniSMB 网络性能测试 免费版本安装指南

    1) 烧录Image至USB 在Linux环境下可以运行以下命令(假设usb设备符号为/dev/sdb): root# tar -Jxf minismb-free-edition.img.tar.xz ...

  3. 用阿里云ecs部署kubernetes/K8S的坑(VIP、slb、flannel、gw模式)

    1 阿里云ecs不支持keepalived vip 1.1 场景描述 本来计划用keepalived配合nginx做VIP漂移,用以反代多台master的apiserver的6443端口,结果部署了v ...

  4. Java之浅拷贝和深拷贝

    [概述] Java中的对象拷贝 ( Object Copy ) 是指将一个对象的所有属性(成员变量)拷贝到另一个有着相同类类型的对象中去.例如,对象 A 和对象 B 都属于类 S,具有属性 a 和 b ...

  5. history-back

    ;!function(pkg, undefined){ //此声明函数在xback.js文件里有,在app.js里必须再声明一次,不然监听返回事件失败 var STATE = 'x-back'; va ...

  6. codeforces 758D

    D. Ability To Convert time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. 高并发之Phaser、ReadWriteLock、StampedLock

    本系列研究总结高并发下的几种同步锁的使用以及之间的区别,分别是:ReentrantLock.CountDownLatch.CyclicBarrier.Phaser.ReadWriteLock.Stam ...

  8. js load more select

    js load more select searchable scroll load more append to list refs xgqfrms 2012-2020 www.cnblogs.co ...

  9. H5 页面如何展示大量的表格数据

    H5 页面如何展示大量的表格数据 列数过多 图表化 refs xgqfrms 2012-2020 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

  10. Mac 外接 Dell 4K 显示器字体模糊解决办法

    Mac 外接 Dell 4K 显示器字体模糊解决办法 mac mini mbp 2020 refs https://zhuanlan.zhihu.com/p/52100804 xgqfrms 2012 ...