当前位置:网站首页>Pat grade a real problem 1166
Pat grade a real problem 1166
2022-07-03 07:03:00 【Ray. C.L】

Ideas : Judge whether it is a group , If yes, see if you can add a vertex
Code :
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 300;
bool st[N];
int g[N][N];
int main()
{
int n,m;
scanf("%d%d", &n, &m);
while (m -- ){
int x,y;
scanf("%d%d", &x, &y);
g[x][y] = g[y][x] = true;
}
scanf("%d", &m);
for(int t = 1; t <= m; t++){
int cnt ;
memset(st, 0, sizeof st);
scanf("%d", &cnt);
while(cnt-- ){
int x;
scanf("%d", &x);
st[x] = true;
}
bool is_clique = true;
for(int i = 1; i <= n; i++)
for(int j = i + 1; j <= n; j++)
if(st[i]&&st[j]&&!g[i][j])
is_clique = false;
if(!is_clique){
printf("Area %d needs help.\n",t);
}else{
int id = 0;
for(int i = 1; i <= n; i++){
if(!st[i]){
bool is_join = true;
for(int j = 1; j <= n; j++)
if(st[j]&&!g[i][j]){
is_join = false;
break;
}
if(is_join){
id = i;
break;
}
}
}
if(id) printf("Area %d may invite more people, such as %d.\n", t, id);
else printf("Area %d is OK.\n", t);
}
}
}
边栏推荐
- Advanced API (character stream & net for beginners)
- dataworks自定義函數開發環境搭建
- Flask Foundation
- Reading notes of "learn to ask questions"
- Realize PDF to picture conversion with C #
- Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
- instanceof
- 2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
- EasyExcel
- DNS forward query:
猜你喜欢

Daily question brushing record (11)

Sorting out the core ideas of the pyramid principle

DBNet:具有可微分二值化的实时场景文本检测

Flask Foundation

【类和对象】深入浅出类和对象

VMware virtual machine C disk expansion

golang操作redis:写入、读取hash类型数据

Dbnet: real time scene text detection with differentiable binarization

How to specify the execution order for multiple global exception handling classes

深度学习参数初始化(一)Xavier初始化 含代码
随机推荐
Redis command
【code】偶尔取值、判空、查表、验证等
crontab定时任务
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
【code】if (list != null && list.size() > 0)优化,集合判空实现方式
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
Daily question brushing record (11)
Reading notes of "learn to ask questions"
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
Advanced API (byte stream & buffer stream)
DBNet:具有可微分二值化的实时场景文本检测
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
Shim and Polyfill in [concept collection]
2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
Tool class static method calls @autowired injected service
centos php7.2.24升级到php7.3
IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library
[LeetCode]404. Sum of left leaves
Use the jvisualvm tool ----- tocmat to start JMX monitoring