当前位置:网站首页>Pat class a 1142 largest regiment
Pat class a 1142 largest regiment
2022-06-12 16:52:00 【Clavier sonata 】
In an undirected graph , If a vertex subset satisfies that any two different vertices in the subset are connected , Then this set of vertices is called a clique .
If a clique cannot be expanded into a larger clique by adding a new vertex , Then the regiment is called the largest regiment .
Now? , You need to determine whether a given vertex subset can form a maximum clique .
Input format
The first line contains two integers Nv and Ne, Represents the number of points and edges of an undirected graph, respectively .Next Ne That's ok , Each line contains two integers a,b, Indication point a Sum point b There is an edge between .
Number of all points from 1 To Nv.
Another line , Contains integers M, It means the number of inquiries .
Next M That's ok , Each line describes a subset of query vertices , First, include an integer K, Indicates the number of points contained in the subset , Then it contains K It's an integer , Express K Number of different vertices .
All numbers in a row are separated by a space .
Output format
Each group of questions outputs a conclusion in one line .If a given subset is the largest clique , The output Yes, If it's a regiment , But not the largest group , The output Not Maximal, If it's not a regiment at all , The output Not a Clique.
Data range
1≤Nv≤200,
1≤Ne≤Nv(Nv−1)2,
1≤M≤100,
1≤K≤Nv
sample input :
8 10
5 6
7 8
6 4
3 6
4 5
2 3
8 2
2 7
5 3
3 4
6
4 5 4 3 6
3 2 8 7
2 2 3
1 1
3 4 3 6
3 3 2 1
sample output :
Yes
Yes
Yes
Yes
Not Maximal
Not a Clique
My solution :
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
bool g[N][N];
int nodes[N];
int n, m;
int main(){
cin >> n >> m;
while(m -- ){
int a, b;
cin >> a >> b;
g[a][b] = g[b][a] = true;
}
int k;
cin >> k;
while(k --){
int num;
cin >> num;
for(int i = 1; i <= num; i ++ ){
cin >> nodes[i];
}
bool flag = true;
for(int i = 1; i <= num; i ++ ){
if(!flag) break;
for(int j = i + 1; j <= num; j ++ ){
if(!g[nodes[i]][nodes[j]]){
flag = false;
break;
}
}
}
if(flag){
bool is_max = true;
for(int i = 1; i <= n; i ++ ){
bool flag2 = true;
for(int j = 1; j <= num; j ++ ){
if(!g[i][nodes[j]]) flag2 = false;
}
if(flag2){
is_max = false;
break;
}
}
if(is_max) puts("Yes");
else puts("Not Maximal");
}
else{
puts("Not a Clique");
}
}
return 0;
}边栏推荐
猜你喜欢

薛定谔的日语学习小程序源码

The process of "unmanned aquaculture"
![[MySQL] Cartesian product - multi table query (detailed explanation)](/img/46/6a9a62b35eaa538232da1d738b3931.jpg)
[MySQL] Cartesian product - multi table query (detailed explanation)

2080虚拟机登录命令

Cookies and sessions

Extract the new Chinese cross modal benchmark zero from 5billion pictures and texts, and Qihoo 360's new pre training framework surpasses many SOTAS
![[Hunan University] information sharing of the first and second postgraduate entrance examinations](/img/15/298ea6f7367741e1e085007c498e51.jpg)
[Hunan University] information sharing of the first and second postgraduate entrance examinations

Recommend AI intelligent drawing repair software

generate pivot data 0

Mongodb learning and sorting (basic command learning of users, databases, collections and documents)
随机推荐
2022-2028 global press dehydrator industry research and trend analysis report
博士申请 | 新加坡国立大学Xinchao Wang老师招收图神经网络方向博士/博后
Token and idempotency
如何基于CCS_V11新建TMS320F28035的工程
Differences between SQL and NoSQL of mongodb series
[DSP video tutorial] DSP video tutorial Issue 8: performance comparison of DSP library trigonometric function, C library trigonometric function and hardware trigonometric function, and accuracy compar
Uniapp壁纸小程序源码/双端微信抖音小程序源码
Recommend AI intelligent drawing repair software
"Shandong University project training" rendering engine system (8-END)
890. 查找和替换模式 / 剑指 Offer II 080. 含有 k 个元素的组合
Anyone who watches "Meng Hua Lu" should try this Tiktok effect
su直接切换到超级管理员模式,这样很多报错都可以避免了
Object. Keys traverses an object
Servlet API
Iscc-2022 part WP
Idea displays services on the console to uniformly manage all jetty services,
Project training of Shandong University rendering engine system (III)
How to construct PostgreSQL error codes
[adult Liu Er - pytorch deep learning practice] notes with learning (I)
std::set compare