AcWing 4278. 峰会
原题链接
简单
作者:
YAX_AC
,
2024-12-11 19:53:35
,
所有人可见
,
阅读 3
//tentative暂定的 arrangements安排
#include<bits/stdc++.h>
using namespace std;
const int N = 500;
bool g[N][N];
int n,m,k;
int st[N];
int t,a[N];
bool f(int x,int y)
{
return g[x][y] || g[y][x];
}
bool check()
{
for(int j = 0; j<t; j++)
for(int k = j+1; k<t; k++)
{
if(g[a[j]][a[k]]==0 && g[a[k]][a[j]]==0)
{
return false;
}
}
return true;
}
int main()
{
cin>>n>>m;
for(int i = 1; i<=m; i++)
{
int a,b,c;
cin>>a>>b;
g[a][b] = true;
g[b][a] = true;
}
cin>>k;
for(int i = 1; i<=k; i++)
{
cin>>t;
memset(a,0,sizeof a);
memset(st,0,sizeof st);
for(int j = 0; j<t; j++)
{
cin>>a[j];
st[a[j]] = 1;
}
if(check())
{
int g = 0;
for(int j = 1; j<=n; j++)
{
if(st[j] == 0)
{
int cnt = 0;
for(int k = 0; k<t; k++)
{
if(f(j,a[k])) cnt++;
}
if(cnt == t)
{
g = j;
break;
}
//cout<<j<<' '<<cnt<<endl;
}
}
if(g) printf("Area %d may invite more people, such as %d.\n",i,g);
else printf("Area %d is OK.\n",i);
}
else
{
printf("Area %d needs help.\n",i);
}
}
return 0;
}