1166 Summit

news/2024/11/17 21:17:08/

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.
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int n, m, k, u, v, num, flag, ans;
vector<int>g[210];
int a[210];
bool f[210][210];
bool vis[210];int main() {cin >> n >> m;for (int i = 1; i <= n; i++) {f[i][i] = 1;}for (int i = 0; i < m; i++) {cin >> u >> v;g[u].push_back(v);g[v].push_back(u);f[u][v] = f[v][u] = 1;}cin >> k;for (int t = 1; t <= k; t++) {cin >> num;flag = 0;memset(vis, 0, sizeof(vis));for (int i = 0; i < num; i++) {cin >> a[i];vis[a[i]] = 1;}for (int i = 0; i < num; i++) {if (flag == 1) {break;}for (int j = i + 1; j < num; j++) {if (!f[a[i]][a[j]]) {flag = 1;break;}}}if (flag == 1) {printf("Area %d needs help.\n", t);} else {for (int i = 1; i <= n; i++) {if (!vis[i]) {for (int j = 0; j < num; j++) {if (!f[i][a[j]]) {flag = 2;break;} else {ans = i;flag = 3;}}}if (flag == 3) {printf("Area %d may invite more people, such as %d.\n", t, ans);break;}}if (flag != 3) {printf("Area %d is OK.\n", t);}}}return 0;
}

http://www.ppmy.cn/news/4928.html

相关文章

Docker镜像

镜像是一种轻量级、可执行的独立软件包&#xff0c;它包含运行某个软件所需的所有内容&#xff0c;我们把应用程序和配置依赖打包好形成一个可交付的运行环境(包括代码、运行时需要的库、环境变量和配置文件等)&#xff0c;这个打包好的运行环境就是image镜像文件。 只有通过这…

基于Android 的大学生理财系统

1.研究现状&#xff1a; 随着时代的发展&#xff0c;智能手机已经成为大学生日常学习生活中必不可少的一部分&#xff0c;在校大学生作为收入有限的消费群体&#xff0c;在当下多元化的日常消费中&#xff0c;大学生经常成为月光族甚至超支&#xff0c;理性消费健康生活显得尤为…

“空天地海”一体化的海上应急通信网络技术综述

【摘 要】随着航运业的不断发展,现有的海上应急通信技术资源分散,已经难以应对复杂的海上紧急情况。基于多通信平台融合,“空天地海”一体化的海上应急通信网络应运而生。介绍了海上应急通信研究背景、意义及发展现状,阐述了天基、空基、岸基、海基通信手段及其在海上应急…

PCL 点云配准衡量指标

0. 简介 PCL作为目前最为强大的点云库&#xff0c;内部存在有大量集成好的算法。而对于数据量大、非同源、含大量噪声且部分重叠的激光点云与影像重建点云&#xff0c;其稀疏程度、噪声程度等不同&#xff0c;非重叠区域的面积很大。真实场景的点云尤其是影像重建点云噪声较多…

STM32 如何使用定时器心跳检测串口数据

目录 原理简介 定时时间 具体代码 定时函数取值范围 原理简介 定时器就是一直隔一段时间会进来处理数据&#xff0c;如果处理串口例如9600波特率&#xff0c;那么就需要每过104us进行检测&#xff0c;定时检测的时间只能比104us时间小&#xff0c;不能大。 如果连续检测到…

华为数字化转型之道 实践篇 第八章 数字化交易:让做生意简单、高效

第八章 数字化交易:让做生意简单、高效 交易流对于大多数To B企业而言都是核心业务流之一。交易流既包括信息流,它即关乎客户的满意度,又直接影响企业经营业绩的好坏。 To C场景的挑战在于简单的事情如何在短时间内做亿万遍。而To B场景与此恰恰相反,交易的数量没那么多,…

我国盆栽蔬菜行业发展势头向好 未来市场需求将保持持续攀升态势

盆栽蔬菜是指在花盆或其他容器内种植的蔬菜&#xff0c;供人观赏和采摘食用。盆栽蔬菜分为观果类蔬菜、彩色蔬菜、绿叶保健蔬菜、根茎类蔬菜等几类。其中观果类蔬菜包括彩色甜椒、矮生番茄、樱桃番茄、硬果番茄、观赏茄子、小型辣椒、袖珍西瓜及各种南瓜、甜瓜、西葫芦、黄秋葵…

计算机操作系统笔记总结:Part2 进程与线程

文章目录1 进程1.1 进程的概念、组成与特征1.2 进程的状态与转换1.3 进程的组织1.4 进程控制1.5 进程通信2 线程与多线程模型2.1 线程的概念2.2 线程的实现方式2.3 多线程模型2.4 线程的状态与转换3 处理机调度3.1 调度的三个层次3.2 进程的挂起态与七状态模型3.3 进程调度3.3.…