-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy path1166_Summit (25).cpp
55 lines (52 loc) · 1.52 KB
/
1166_Summit (25).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
#include <iostream>
#include <vector>
using namespace std;
int G[205][205];
bool CheckFullConnected(const vector<int> &area) {
for (int i = 0; i < area.size(); i++) {
int a = area[i];
for (int j = i+1; j < area.size(); j++) {
int b = area[j];
if (G[a][b] == 0) return false;
}
}
return true;
}
int main() {
ios::sync_with_stdio(false);
int n, m, a, b, k, l;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a >> b;
G[a][b] = G[b][a] = 1;
}
cin >> k;
for (int i = 1; i <= k; i++) {
cin >> l;
vector<int> area(l);
vector<bool> vis(n+1, false);
for (int j = 0; j < l; j++) {
cin >> area[j];
vis[area[j]] = true;
}
bool isFullConnected = CheckFullConnected(area);
if(!isFullConnected) cout << "Area " << i << " needs help." << endl;
else {
bool findExtra = false;
for (int j = 1; j <= n; j++) {
if (!vis[j]) {
area.push_back(j);
isFullConnected = CheckFullConnected(area);
area.pop_back();
if (isFullConnected) {
cout << "Area " << i << " may invite more people, such as "<< j << "." << endl;
findExtra = true;
break;
}
}
}
if (!findExtra) cout << "Area " << i << " is OK." << endl;
}
}
return 0;
}