PAT-1154(Vertex Coloring )+map使用+vector建图+set的使用
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的使用的更多相关文章
- PTA 1154 Vertex Coloring
题目链接:1154 Vertex Coloring A proper vertex coloring is a labeling of the graph's vertices with colors ...
- PAT 甲级 1154 Vertex Coloring
https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 A proper vertex color ...
- pat甲级 1154 Vertex Coloring (25 分)
A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Dijkstra算法堆优化(vector建图)
#include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> ...
- zzulioj--1831-- 周末出游(vector建图+dfs)
1831: 周末出游 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 22 Solved: 8 SubmitStatusWeb Board Descr ...
随机推荐
- hdu3905 Sleeping (区间dp)
Problem Description ZZZ is an enthusiastic ACMer and he spends lots of time on training. He always s ...
- 获取csc.exe路径
using System.Runtime.InteropServices; var frameworkPath = RuntimeEnvironment.GetRuntimeDirectory(); ...
- 【Azure Redis 缓存】使用Python代码获取Azure Redis的监控指标值 (含Powershell脚本方式)
问题描述 通过Metrics监控页面,我们能得知当前资源(如Redis)的运行情况与各种指标.如果我们需要把指标下载到本地或者生成JSON数据导入到第三方的监控平台呢?Azure是否可以通过Pytho ...
- While & For 循环
While 循环 可以将 While 循环称为 "条件循环" While 循环语法 # 条件为 true 就执行循环体代码,条件变为 false 循环结束 while 条件 do ...
- (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (127.0.0.1:3306)\n')
使用python 3.7 pymssql 连接本地mysql 5.6 报错 解决:参考 https://www.cnblogs.com/springbrotherhpu/p/11503139.html ...
- Linux 驱动框架---cdev字符设备驱动和misc杂项设备驱动
字符设备 Linux中设备常见分类是字符设备,块设备.网络设备,其中字符设备也是Linux驱动中最常用的设备类型.因此开发Linux设备驱动肯定是要先学习一下字符设备的抽象的.在内核中使用struct ...
- Loss_Function_of_Linear_Classifier_and_Optimization
Loss_Function_of_Linear_Classifier_and_Optimization Multiclass SVM Loss: Given an example(xi, yi& ...
- RT-Thread学习笔记2-互斥量与信号量
目录 1. 临界区保护 1.1 方法一:关闭系统调度保护临界区 1.2 方法二:互斥特性保护临界区 2. 信号量 2.1 信号量的定义 2.2 信号量的操作 3. 生产者.消费者问题 4. 互斥量 4 ...
- javascript 克隆对象/数组的方法 clone()
1 11 javascript 克隆对象/数组的方法 clone() 1 demo: code: 1 var Obj; 2 let clone = (Obj) => { 3 var buf; ...
- Swift All in One
Swift All in One Swift 5.3 https://github.com/apple/swift-evolution Xcode https://developer.apple.co ...