当前位置:网站首页>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);
}
}
}
边栏推荐
- 服务器如何设置多界面和装IIS呢?甜甜给你解答!
- Error c2017: illegal escape sequence
- Unit test framework + Test Suite
- [vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
- How to plan well?
- golang操作redis:写入、读取kv数据
- Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
- Search engine Bing Bing advanced search skills
- [set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
- 10000小时定律不会让你成为编程大师,但至少是个好的起点
猜你喜欢
How to specify the execution order for multiple global exception handling classes
vmware虚拟机C盘扩容
POI excel percentage
Inno setup production and installation package
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
Liang Ning: 30 lectures on brain map notes for growth thinking
深度学习参数初始化(一)Xavier初始化 含代码
【类和对象】深入浅出类和对象
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
Winter vacation work of software engineering practice
随机推荐
Software testing assignment - day 3
Specified interval inversion in the linked list
Upgrade CentOS php7.2.24 to php7.3
Summary of the design and implementation of the weapon system similar to the paladin of vitality
Split small interface
2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
Laravel Web框架
Unittest attempt
Flask Foundation
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
Basic teaching of crawler code
Use the jvisualvm tool ----- tocmat to start JMX monitoring
2021 year end summary
Interface learning
golang操作redis:写入、读取kv数据
Unit test notes
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
Asynchronous programming: async/await in asp Net
CentOS php7.3 installing redis extensions
Integration test practice (1) theoretical basis