#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
set<int>v[];
int a[];
int vis[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
for(int i=;i<=m;++i){
int x,y;
cin>>x>>y;
v[x].insert(y);
v[y].insert(x);
}
int k;
cin>>k;
for(int i=;i<=k;++i){
int num;
cin>>num;
if(num==){
cout<<"Area "<<i<<" needs help.";
cout<<"\n";
continue;
}
for(int j=;j<=num;++j)
cin>>a[j];
int flag=;
for(int k=;k<=num;++k){
for(int j=;j<=num;++j){
if(k==j)
continue;
if(!v[a[k]].count(a[j])){
flag=;
}
}
}
if(flag){
cout<<"Area "<<i<<" needs help.";
cout<<"\n";
continue;
}
memset(vis,,sizeof(vis));
for(int j=;j<=num;++j){
for(auto it:v[a[j]])
++vis[it];
}
int ans=;
for(int j=;j<=n;++j)
if(vis[j]==num){
ans=j;
break;
}
if(ans){
cout<<"Area "<<i<<" may invite more people, such as "<<ans<<".";
cout<<"\n";
continue;
}
cout<<"Area "<<i<<" is OK.";
cout<<"\n";
}
return ;
}

2019冬季PAT甲级第三题的更多相关文章

  1. 2019冬季PAT甲级第四题

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct node{ ...

  2. 2019冬季PAT甲级第二题

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct{ int ...

  3. 2019冬季PAT甲级第一题

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ][]; ][]; ]; string ...

  4. 2019秋季PAT甲级_备考总结

    2019 秋季 PAT 甲级 备考总结 在 2019/9/8 的 PAT 甲级考试中拿到了满分,考试题目的C++题解记录在这里,此处对备考过程和考试情况做一个总结.如果我的方法能帮助到碰巧点进来的有缘 ...

  5. PAT甲级训练刷题代码记录

    刷题链接:https://www.patest.cn/contests/pat-a-practise 1001 #include <iostream> #include <stdio ...

  6. 2019秋季PAT甲级_C++题解

    2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Fore ...

  7. PAT甲级 Dijkstra 相关题_C++题解

    Dijkstra PAT (Advanced Level) Practice Dijkstra 相关题 目录 <算法笔记>重点摘要 1003 Emergency (25) <算法笔记 ...

  8. PAT甲级 散列题_C++题解

    散列 PAT (Advanced Level) Practice 散列题 目录 <算法笔记> 重点摘要 1002 A+B for Polynomials (25) 1009 Product ...

  9. PAT甲级 二叉树 相关题_C++题解

    二叉树 PAT (Advanced Level) Practice 二叉树 相关题 目录 <算法笔记> 重点摘要 1020 Tree Traversals (25) 1086 Tree T ...

随机推荐

  1. ES源码阅读过程

    HTTP请求的controller:RestController 游标的作用 相当于建立了一个 limit的priorityqueue 不用游标的话,相当于建立一个limit+offset的prior ...

  2. django学习,captcha图形验证码的使用

    很多网站在登录或者注册的时候都有验证码,让你去输入. 刚好有这么一款插件,可以满足这个功能 首先,先pip install  django-simple-captcha 然后再setting里添加,如 ...

  3. wpf 程序启动显示图片

    一.设置图片的生成操作 程序启动时会出现0.5秒的图片显示,再显示程序界面. 二.写代码实现相同效果 /// <summary> /// App.xaml 的交互逻辑 /// </s ...

  4. python UI自动化之js操作

    js处理iframe无需先切换到iframe上,再切回来操作.它可以在iframe上和主页面上来回自由操作. switch方法需要先切换到iframe上,操作完之后又的切换回来(很容易忘记切换回来), ...

  5. element模态框dialog中的select组件中选中无反应无显示

    https://blog.csdn.net/PGguoqi/article/details/90240650 在vue里,当你对一个不存在的属性或对象直接“.”进行赋值,或者对数组不存在的索引项直接用 ...

  6. 2020算法设计竞赛 H 坐火车

    链接:https://ac.nowcoder.com/acm/contest/3005/H来源:牛客网 大致题意:让我们针对每一个数,求这个数左区间和右区间颜色相同(也就是数字相同)得对数: 比如:左 ...

  7. python3练习100题——021

    题目很容易,只要理清了数学思想就可以解出来,所以本来不是很喜欢这种题. 后来看到有大神用递归解,觉得还是很值得学习的. 原题链接:http://www.runoob.com/python/python ...

  8. 简单的xss注入和防御

    什么是xss注入: xss通常就是通过巧妙的方法注入指令到指定页面,使用户加载执行的恶意的js(或者其他类型)的代码,攻击者会获取用户的一系列信息,如cookie等,从而进行其他用户信息的盗取 为什么 ...

  9. MySQL学习(九)小结

    redo-log 和 bin-log 是如何联系起来的? update 语句在更新的时候先更新内存后,写 redo-log 然后 bin-log ,其中后面一步是使用了两阶段提交, 也就是每一个更新都 ...

  10. 源码安装python 报错,openssl: error while loading shared libraries: libssl.so.1.1

    在执行openssl version出现如下错误: openssl: error while loading shared libraries: libssl.so.1.1: cannot open ...