题目

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.

Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N (≤ 200), the number of heads in the summit, and M, the number of friendship relations. Then M lines follow, each gives a pair of indices of the heads who are friends to each other. The heads are indexed from 1 to N.

Then there is another positive integer K (≤ 100), and K lines of tentative arrangement of rest areas follow, each first gives a positive number L (≤ N), then followed by a sequence of L distinct indices of the heads. All the numbers in a line are separated by a space.

Output Specification:
For each of the K areas, print in a line your advice in the following format:

if in this area everyone is a direct friend of everyone, and no friend is missing (that is, no one else is a direct friend of everyone in this area), print Area X is OK…

if in this area everyone is a direct friend of everyone, yet there are some other heads who may also be invited without breaking the ideal arrangement, print Area X may invite more people, such as H. where H is the smallest index of the head who may be invited.

if in this area the arrangement is not an ideal one, then print Area X needs help. so the host can provide some special service to help the heads get to know each other.

Here X is the index of an area, starting from 1 to K.

Sample Input:
8 10
5 6
7 8
6 4
3 6
4 5
2 3
8 2
2 7
5 3
3 4
6
4 5 4 3 6
3 2 8 7
2 2 3
1 1
2 4 6
3 3 2 1

Sample Output:
Area 1 is OK.
Area 2 is OK.
Area 3 is OK.
Area 4 is OK.
Area 5 may invite more people, such as 3.
Area 6 needs help.

解释

本题与1142同,首先判断是否是各个点彼此相连,若相连判断是否有其它顶点与集合中的顶点都直接相连。最终得到三种情况并输出。

正确答案

#include<iostream>
#include<climits>
#include<cctype>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
bool e[205][205];
int main(){int n, m , k, a ,b;cin >> n >> m;fill(e[0], e[0] + 205*205, false);for(int i = 0; i < m; i++){cin >> a >> b;e[a][b] = true;e[b][a] = true;}cin >> k;for(int i = 1; i <= k; i++){bool flag1 = true;cin >> a;vector<int> v(a);vector<bool> exist(n + 1, false);for(int j = 0; j < a; j++){scanf("%d", &v[j]);exist[v[j]] = true;}for(int j = 0; j < a && flag1; j++){for(int l = j + 1; l < a && flag1; l++)if(!e[v[j]][v[l]]){flag1 = false;break;}}if(!flag1) printf("Area %d needs help.\n", i);else{bool flag3= true;for(int j = 1; j <= n; j++){if(!exist[j]){int flag2 = true;for(int l = 0; l <a; l++){if(!e[j][v[l]]){flag2= false;break;}}if(flag2) {printf("Area %d may invite more people, such as %d.\n", i, j);flag3 = false;break;}}}if(flag3)   printf("Area %d is OK.\n", i);}}return 0;
}

2019年12月PAT甲级 第三题 Summit(1166)题解相关推荐

  1. 2019年12月PAT甲级满分备考经验

    PAT甲级满分备考经验 答题过程 备考经验 答题过程   总得来说,我觉得我幸运,碰上了一次PAT甲级题目相当简单(1085中有190人满分),最终提前一小时交卷,实时排名为35.   我按照1 2 ...

  2. 2019年12月PAT甲级 第一题 Good in C(1164)题解

    题目 When your interviewer asks you to write "Hello World" using C, can you do as the follow ...

  3. 大学英语计算机my dream 150,2019年12月网络教育统考模拟题二—大学英语A

    大学英语 A 2 一.阅读理解 1. Do you find getting up in the morning so difficult that it's painful? This might ...

  4. 忍者必须死3 通关 服务器维护,《忍者必须死3》2019年12月12日停服维护公告

    在忍者必须死3手游中2019年12月12日更新了哪些有趣的内容呢?在本次维护更新中相信大家对此也都是相当关心的呢!那么不清楚的话下面就来看一下吧! 亲爱的忍忍 为了给忍忍们带来更好的游戏体验,< ...

  5. epubbuilder 过期_记者调查|浠水县思源实验学校向学生发过期牛奶,生产日期2019年12月14日...

    楚天都市报11月2日讯(记者董淑健 通讯员魏学建) 生产日期2019年12月14日,保质期6个月.过期几个月的牛奶能喝吗?几天前,居然通过学校食堂发到了学生手中. 浠水县思源实验学校的一些学生家长对此 ...

  6. 江西省2019计算机二级报名日期,2020年3月江西计算机等级报名时间、报名入口【2019年12月18日-27日】...

    [导语]<2020年3月江西全国计算机等级考试工作通知>现已发布.2020年3月江西计算机等级报名时间:2019年12月18日-27日,考试时间:2020年3月28日-30日,小编现将报考 ...

  7. 【报告分享】2019年12月郭广昌混沌课程ppt(附下载链接)

    今天给大家分享的报告是复星国际董事长郭广昌先生于2019年12月在混沌大学上的课程ppt<穿越企业周期,重启增长引擎>,课程包括三个部分:1.如何理解企业周期:2.如何穿越企业周期:3.如 ...

  8. wps两列数据分别作为xy轴_一图胜千字:科研论文插图/数据处理和图表制作学习会(2019年12月2729日 上海)...

    我是吸铁石,无论你多强大,只要你离我近,就会被磁化 放射技师考试资料独家整理历年真题.考点分析.名师讲解.影像资讯. 执业技师资格考试在路上,放射技师之路,你我同行. (全文共计1485字,预计阅读时 ...

  9. 网络购物属于计算机应用中的,2019年12月网络教育统考《计算机应用基础》复习题(六)...

    2019年12月统考即将进行,距离考试也没几天了,在考前用习题练练手是非常有必要,小编在下文为你提供了一份2019年12月网络教育统考<计算机应用基础>复习题(六)供你复习. 一.单选题 ...

最新文章

  1. 特定场景下Yolo改进算法:Poly-Yolo
  2. 养成良好的学习习惯-浅谈学习方法(1)
  3. Win8.1无法安装更新,提示0x800*****错误的解决方法
  4. 编程软件python是什么-现在编程软件有哪些?常用是哪一种?
  5. matlab radn,如何用matlab编写randn函数?
  6. php环境被80端口占用无法使用什么办
  7. linux lvm uuid绑定,LVM:“找不到具有uuid的设备”但是blkid找到了UUID
  8. 装×失败的后果。。。 | 今日最佳
  9. 【堆】【DP】Niyaz and Small Degrees(luogu 7600[APIO 2021 T3]/luogu-CF1119F)
  10. CSS的三种定位,月薪30K
  11. python计算两字符串中的位置_python – 计算两个字符串之间距离的算法
  12. 腐蚀单机服务器怎么不稳定,腐蚀有什么指令?基本指令及服务器指令汇总
  13. 热感传导不能证明经络的存在
  14. 总结完全二叉树、满二叉树、二叉排序树、二叉平衡树
  15. OpenStack网络QoS
  16. 发布Flv合并器的.net版
  17. 简单的超市会员管理系统
  18. wps如何保存最终状态_Word 无法保存“最终状态”
  19. MySQL变量的使用
  20. c语言中1%3c%3c2 什么意思,c语言练习题

热门文章

  1. 计算机科学中具有特殊含义或易误解混淆的术语辨析
  2. 编译器LLVM-MLIR-Intrinics-llvm backend-instruction
  3. 【JeecgBoot 2】低代码开发平台完全手册
  4. Ubuntu 22.04 记录一次安装百度输入法的过程
  5. 按键精灵获取Mac地址
  6. 自制Jlink_OB(STM32c8t6)
  7. ceaspectusG超级智能闸口,革新科技箱况残损检测,识别率99.95%,全自动化进出闸,应用智慧港口码头,智慧无人堆场
  8. 【优化求解】基于精英反向学习带扰动因子的混沌蚁狮算法(EOPCALO)求解单目标优化问题附matlab代码
  9. 基于JavaWeb二手商城设计与实现
  10. 基于SSM实现的仓库管理系统