当前位置:网站首页>L2-023 图着色问题 (25 分)
L2-023 图着色问题 (25 分)
2022-04-23 00:33:00 【hys__handsome】
题目详情 - L2-023 图着色问题 (25 分) (pintia.cn)
思路:题意是判断是否为k染色的解,所以用set存颜色,不等k时就一定不是解,然后轮询每个点的相邻点是否颜色相同即可
#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://blog.csdn.net/hys__handsome/article/details/124347982
边栏推荐
- (transfer) remote access to window remote desktop win10 through external network
- Calculation of plot ratio by ArcGIS
- Making 3D planning drawings with ArcGIS
- Configuration parameters of common product module models of Beifu
- At the age of 33, he has worked for ten years and was laid off. The so-called experience is not worth money at all
- 市场格局进入重构期,ESP频繁「召回」,中国供应商「乘势而上」
- ArcMap spatial connection and intersection tool
- 在Google工作的十年,也是我开心的十年
- ArcGIS TIN地表面与栅格地表面的生成与互相转换
- A tikv hard disk usage problem caused by GC not working caused by ticdc exception
猜你喜欢

Making 3D planning drawings with ArcGIS

Analysis and application of conditional compilation

【图像分类】用最简短的代码复现SeNet,小白一定要收藏(keras,Tensorflow2.x)

湖泊遥感研究进展(概述)

Generation and mutual conversion of ArcGIS tin ground surface and grid ground surface

while (n-- > 0) 的用法

CAS unified identity authentication (II): overlay configuration management

Installing MySQL in centos7

C#/.Net 使用QuestPDF操作生成PDF更快更高效!

CAS unified identity authentication (III): external independent configuration
随机推荐
MySQL -- operation of database
Absolute positioning does not use left, right, top, bottom and other attributes
ArcGIS 地表TIN面数据的符号化
ACWing春季每日一题——你知道ABC吗
植被物候參數遙感研究進展(好文分享)
程序员怎么找工作?程序员找工作越来越难怎么办?
倍福NC轴走速度模式
ArcGIS TIN地表面与栅格地表面的生成与互相转换
ArcGIS urban living area land suitability evaluation (III)
MySQL -- database foundation
Addition, deletion, modification and query of MySQL table (Advanced)
The story of tidb and I met unprepared, but I wanted to say how lucky I was to meet you
智能无线传输模组,CV5200助力无人机mesh组网,无线通信传输方案
【圖像分類】——來來來,幹了這碗EfficientNet實戰(Pytorch)
湖泊遥感研究进展(概述)
ArcGIS 制作3D规划图纸
Mitsubishi fx5u configures iebasic setting of mr-je-c servo driver
Learning Android 8 from scratch -- threads and services
Alternative scheme of 24V ~ 48V magnetic absorption track lamp fs2459 to mp2459
El2124 module wiring and pin meaning