-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaximal Clique.cpp
62 lines (60 loc) · 1.33 KB
/
Maximal Clique.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
#include <iostream>
int edage[210][210] = {{0}};
int a[210];
int count = 0;
int main()
{
int n, m;
std::cin >> n >> m;
for (int i = 0; i < m; i++)
{
int x, y;
std::cin >> x >> y;
edage[x][y] = 1;
edage[y][x] = 1;
}
int k;
std::cin >> k;
for (int i = 0; i < k; i++)
{
int temp;
int flag = 0;
count = 0;
std::cin >> temp;
std::cin >> a[count++];
for (int j = 1; j < temp; j++)
{
std::cin >> a[count];
for (int p = 0; p < count; p++)
{
if (edage[a[count]][a[p]] != 1)
flag = 1;
}
count++;
}
if (flag == 1)
std::cout << "Not a Clique" << std::endl;
else
{
int j;
for (j = 1; j < n + 1; j++)
{
int p;
for (p = 0; p < count; p++)
{
if (j == a[p] || edage[j][a[p]] == 0)
break;
}
if (p == count)
break;
}
if (j < n + 1)
std::cout << "Not Maximal" << std::endl;
else
{
std::cout << "Yes" << std::endl;
}
}
}
return 0;
}