当前位置:网站首页>L2-023 graph coloring problem (25 points)
L2-023 graph coloring problem (25 points)
2022-04-23 00:36:00 【hys__ handsome】
Topic details - L2-023 Graph coloring problem (25 branch ) (pintia.cn)
Ideas : The meaning of the question is to judge whether it is k Solution of coloring , So use set Save color , Unequal k Time must not be the solution , Then poll whether each adjacent point has the same color
#include<iostream>
#include<vector>
#include<set>
using namespace std;
const int N = 510;
vector<vector<int>> g(N);
int color[N];
int main(){
int n,m,k;
cin>>n>>m>>k;
while(m--){
int u,v;
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
int q;
cin>>q;
while(q--){
set<int> s;
for(int i = 1; i <= n; i++){
cin>>color[i];
s.insert(color[i]);
}
if(s.size() != k) {
puts("No");
continue;
}
bool flag = true;
for(int i = 1; i <= n; i++) {
for(int num:g[i])
if(color[num] == color[i]){
flag = false;
break;
}
}
if(flag) puts("Yes");
else puts("No");
}
return 0;
}
版权声明
本文为[hys__ handsome]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230033479268.html
边栏推荐
- L2-022 重排链表 (25 分) 链表操作
- 牛客NC13251模
- 为什么进入上一个输入框后,下一个输入框光标进不去(是只能在前部分才能点击光标进入输入框,光标点击输入框后部分不起作用)
- openresty安装与入门
- Kotlin - 继承 open
- Ten years of working at Google is also a happy decade for me
- while (n-- > 0) 的用法
- MP2459被完美替代内部集成有功率MOSFET管FS2459的60V0.5A降压IC
- MySQL built-in function
- Process comma separated strings and sort the output in ascending dictionary order
猜你喜欢

C#/. Net uses questpdf operation to generate PDF faster and more efficient!

ArcGIS 制作3D规划图纸

(turn to) C # best tool set: IDE, analysis, automation tools, etc

ArcGIS urban living area land suitability evaluation (III)

Differences of lake water color, water environment and hydrological remote sensing

将 AWS S3 数据迁移至 TiDB Cloud 集群

C# WPF UI框架MahApps切换主题

Research progress of Lake remote sensing (Overview)

Making 3D remote sensing image map with ArcGIS

Progrès de la recherche sur la télédétection des paramètres phénologiques de la végétation
随机推荐
Alternative scheme of 24V ~ 48V magnetic absorption track lamp fs2459 to mp2459
L2-013 红色警报 (25 分)
CAS unified identity authentication (III): external independent configuration
repeat_ dijkstra
Generation and mutual conversion of ArcGIS tin ground surface and grid ground surface
Buuctf hidden key
How do programmers find jobs? What if it becomes more and more difficult for programmers to find a job?
ArcGIS 城市生活区用地适宜性评价(一)
The market structure has entered a period of restructuring, ESP has frequently "recalled", and Chinese suppliers "take advantage of the trend"
【圖像分類】——來來來,幹了這碗EfficientNet實戰(Pytorch)
Introduction and usage of connector and analysis of + + and -- operators
C# WPF UI框架MahApps切换主题
A tikv hard disk usage problem caused by GC not working caused by ticdc exception
24V~48V磁吸轨道灯FS2459替代MP2459方案
深度学习基础学习-残差
ifconfig如何获得网卡的统计信息
软考不知道该如何选科?这篇文章解答你的疑惑
C语言 #和 ##
群体智能协同作业与认知计算技术研究
【征文大赛】TiDB 社区专栏第一届征文大赛,快来一次性集齐所有周边吧!