-
Notifications
You must be signed in to change notification settings - Fork 0
/
maximalClique.cpp
67 lines (57 loc) · 1.27 KB
/
maximalClique.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<vector>
#include<iostream>
using namespace std;
int main(){
int g[210][210];
int v,e,m,n,c;
cin>>v>>e;
for (int i = 0; i < e; i++)
{
cin>>m>>n;
g[m][n] = g[n][m] = 1;
}
cin>>c;
for (int i = 0; i < c; i++)
{
cin>>m;
vector<int> cv(m);
bool isC=true, isM= true;
int hash[210] = {0};
for (int j = 0; j < m; j++)
{
cin>>cv[j];
hash[cv[j]] = 1;
}
for (int j = 0; j < m; j++)
{
if(isC == false) break;
for (int k = j+1; k < m; k++)
{
if(g[cv[j]][cv[k]]==0){
isC = false;
break;
}
}
}
if(isC==false){
cout<<"Not a Clique"<<endl;
continue;
}
int k;
for (int j = 1; j < v; j++)
{
if(hash[j]==0){
for (k = 0; k < m; k++)
{
if(g[j][cv[k]] == 0) break;
}
if(k == m){isM = false;}
}
}
if(isM==false){
cout<<"Not Maximal"<<endl;
continue;
}
cout<<"Yes"<<endl;
}
}