当前位置:网站首页>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;
}边栏推荐
- key为断言的map是怎么玩的
- The C programming language (version 2) notes / 8 UNIX system interfaces / 8.6 instances (directory list)
- Three paradigms of database
- Possible problems of long jump in gaussdb
- js監聽用戶是否打開屏幕焦點
- Programmers broke the news: 3 job hopping in 4 years, and the salary has tripled! Netizen: the fist is hard
- Analysis of Nacos config dynamic refresh source code
- generate pivot data 1
- 叶子分享站PHP源码下载
- Understand go modules' go Mod and go sum
猜你喜欢

JVM memory model and local memory

Contract awarding and AQS

Recommend AI intelligent drawing repair software

收藏 | 22个短视频学习Adobe Illustrator论文图形编辑和排版

云开发坤坤鸡乐盒微信小程序源码

The C programming language (version 2) notes / 8 UNIX system interface / 8.7 instance (storage allocator)

Canvas advanced functions (Part 2)

Double write consistency problem

Qt开发高级进阶:初探qt + opengl

How to base on CCS_ V11 new tms320f28035 project
随机推荐
Comprendre le go des modules go. MOD et go. SUM
\Begin{algorithm} notes
程序员爆料:4年3次跳槽,薪资翻了3倍!网友:拳头硬了......
Glove word embedding (IMDb film review emotion prediction project practice)
Qt开发高级进阶:初探qt + opengl
JS monitors whether the user opens the screen focus
Idea displays services on the console to uniformly manage all jetty services,
AssertJ 的异常(Exception )断言
The process of "unmanned aquaculture"
canvas 处理图像(上)
薛定谔的日语学习小程序源码
Information outline recording tool: omnioutliner 5 Pro Chinese version
The C programming language (version 2) notes / 8 UNIX system interface / 8.3 open, create, close, unlink
Joint recruitment notice of ganfei research group of Wuhan University and xuzhenjiang research group of Nanchang University
\Begin{algorithm} notes
Demande de doctorat | xinchao Wang, Université nationale de Singapour
Leetcode 2190. The number that appears most frequently in the array immediately after the key (yes, once)
\begin{algorithm} 笔记
About component value transfer
calibration of sth