当前位置:网站首页>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);
}
}
}
边栏推荐
- POI excel percentage
- 保险公司怎么查高血压?
- 2021 year end summary
- Selenium key knowledge explanation
- 机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
- Sorting out the core ideas of the pyramid principle
- Thoughts in Starbucks
- Class and object summary
- Winter vacation work of software engineering practice
- php artisan
猜你喜欢
卡特兰数(Catalan)的应用场景
3311. 最长算术
Flask Foundation
VMware virtual machine C disk expansion
Pytest -- write and manage test cases
The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?
Use the jvisualvm tool ----- tocmat to start JMX monitoring
Golang operation redis: write and read hash type data
Realize PDF to picture conversion with C #
机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
随机推荐
Abstract learning
[untitled]
Unit test framework + Test Suite
[classes and objects] explain classes and objects in simple terms
Realize PDF to picture conversion with C #
CentOS php7.3 installing redis extensions
Personally design a highly concurrent seckill system
深度学习参数初始化(一)Xavier初始化 含代码
php artisan
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
Mise en place d'un environnement de développement de fonctions personnalisées
修改MySQL密码
“百度杯”CTF比赛 2017 二月场,Web:爆破-1
How to plan well?
vmware虚拟机C盘扩容
Split small interface
Winter vacation work of software engineering practice
Distributed transactions
JMeter test result output
Software testing learning - the next day