当前位置:网站首页>PAT甲级真题1166
PAT甲级真题1166
2022-07-03 07:00:00 【Ray.C.L】

思路:判断是否为团,是的话看能否加入一个顶点
代码:
#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);
}
}
}
边栏推荐
- Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
- 这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
- (翻译)异步编程:Async/Await在ASP.NET中的介绍
- POI excel percentage
- Basic teaching of crawler code
- Software testing learning - day 3
- Selenium key knowledge explanation
- Shim and Polyfill in [concept collection]
- Specified interval inversion in the linked list
- Interfaces and related concepts
猜你喜欢

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'?

Practical plug-ins in idea

Inno Setup 制作安装包

Sorting out the core ideas of the pyramid principle

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

Dbnet: real time scene text detection with differentiable binarization

MySQL installation

10000小時定律不會讓你成為編程大師,但至少是個好的起點

Jenkins

2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
随机推荐
VMware virtual machine C disk expansion
php安装composer
MySQL transaction rollback, error points record
修改MySQL密码
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
每日刷题记录 (十一)
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
[LeetCode]404. Sum of left leaves
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
Integration test practice (1) theoretical basis
[set theory] partition (partition | partition example | partition and equivalence relationship)
Inno setup production and installation package
Getting started with pytest
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
每日刷題記錄 (十一)
UTC time, GMT time, CST time
Tool class static method calls @autowired injected service
Pits encountered in the use of El checkbox group
利用C#实现Pdf转图片
Setting up the development environment of dataworks custom function