当前位置:网站首页>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);
}
}
}
边栏推荐
- [Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
- [untitled]
- UTC时间、GMT时间、CST时间
- Use of framework
- Use the jvisualvm tool ----- tocmat to start JMX monitoring
- Flask Foundation
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
- [classes and objects] explain classes and objects in simple terms
- VMware virtual machine C disk expansion
- Basic components and intermediate components
猜你喜欢
10000小時定律不會讓你成為編程大師,但至少是個好的起點
Application scenarios of Catalan number
[untitled]
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
Software testing assignment - the next day
JMeter test result output
Integration test practice (1) theoretical basis
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
Winter vacation work of software engineering practice
随机推荐
UTC时间、GMT时间、CST时间
mongodb
Understand software testing
CentOS php7.3 installing redis extensions
Advanced API (use of file class)
php artisan
Sorting out the core ideas of the pyramid principle
Abstract learning
卡特兰数(Catalan)的应用场景
Software testing assignment - day 3
HMS core helps baby bus show high-quality children's digital content to global developers
Shim and Polyfill in [concept collection]
DBNet:具有可微分二值化的实时场景文本检测
Redis command
Modify MySQL password
Summary of UI module design and practical application of agent mode
Jenkins
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
Integration test practice (1) theoretical basis