A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone.
Now given a set of tentative arrangements, your job is to tell the organizers whether or not each area is all set.
#include <bits/stdc++.h>
using namespace std;
#define maxn 210
int graph[maxn][maxn];
int init(){
fill(graph[0],graph[0]+maxn*maxn,0);
int n,m;cin>>n>>m;
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
graph[a][b]=graph[b][a]=1;
}
return n;
}
bool is_full_connected(vector<int>v){
for(int i=0;i<v.size()-1;i++){
for(int j=i+1;j<v.size();j++){
if(graph[v[i]][v[j]]==0)
return false;
}
}
return true;
}
int invited=0;//如果不是最大的连通图,用来存储还能邀请的人
bool is_max_connected(int n,vector<int>v){ //这里要把人数作为参数传进来
for(int i=1;i<=n;i++){
if(std::find(v.begin(), v.end(),i)==v.end()){
v.push_back(i);
if(is_full_connected(v)){
invited=i;
return false;
}
else
v.pop_back();
}
}
return true;
}
int main() {
int n=init();
int k;cin>>k;
for(int i=0;i<k;i++){
int l;cin>>l;
vector<int>v;
for(int j=0;j<l;j++){
int temp;cin>>temp;
v.push_back(temp);
}
if(is_full_connected(v)){
if(is_max_connected(n,v))
printf("Area %d is OK.\n",i+1);
else
printf("Area %d may invite more people, such as %d.\n",i+1,invited);
}
else
printf("Area %d needs help.\n",i+1);
}
}