当前位置:网站首页>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);
}
}
}
边栏推荐
- [Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
- Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
- Thoughts in Starbucks
- Stream stream
- Journal quotidien des questions (11)
- vmware虚拟机C盘扩容
- Advanced API (serialization & deserialization)
- Asynchronous programming: async/await in asp Net
- Sorting out the core ideas of the pyramid principle
- Unittest attempt
猜你喜欢

多个全局异常处理类,怎么规定执行顺序

Win 10 find the port and close the port

利用C#实现Pdf转图片

MySQL installation

深度学习参数初始化(一)Xavier初始化 含代码

2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)

Inno Setup 制作安装包

HMS core helps baby bus show high-quality children's digital content to global developers

dataworks自定義函數開發環境搭建

Realize PDF to picture conversion with C #
随机推荐
Strategy mode
Dbnet: real time scene text detection with differentiable binarization
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Distributed lock
Software testing assignment - day 1
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
Tool class static method calls @autowired injected service
DBNet:具有可微分二值化的实时场景文本检测
POI excel percentage
mysql误删root账户导致无法登录
修改MySQL密码
Advanced API (character stream & net for beginners)
MySQL installation
Integration test practice (1) theoretical basis
Inno Setup 制作安装包
How can the server set up multiple interfaces and install IIS? Tiantian gives you the answer!
【code】偶尔取值、判空、查表、验证等
Distributed ID
JMeter JSON extractor extracts two parameters at the same time