7-3 Summit (25分)
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.
主要是写出流程图,做题之前1.仔细仔细仔细审题。2.建模。和那啥哈密顿图很像?还是啥图来着
//如果没有人和这里的人全部是朋友,且这里的人两两都是朋友,就是ok
//如果还有人和这里的所有人都是朋友,就直接输出这个人
//如果不全都是朋友,就输出need help
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
const int maxn = 205;
const int INF = 1000000000;
int G[maxn][maxn];
int main(){
fill(G[0],G[0]+maxn*maxn,INF);
int n,m;//人是从0开始的
cin>>n>>m;
int u,v;
for(int i = 0;i < m; i++){
cin>>u>>v;
G[u][v] = G[v][u] = 1;
}
int q,k,dian;
cin>>q;
for(int i = 1; i <= q; i++){
vector<int> v;
cin>>k;
bool needHelp = false;
bool mayInvite = false;
int inviteIndex;
for(int j = 0; j < k; j++){
cin>>dian;
v.push_back(dian);
}
for(int j = 0; j < k -1;j++){
for(int l = j+1;l < k; l++){
if(G[v[j]][v[l]] == INF){
needHelp = true;
}
}
}
for(int j = 1; j <= n; j++){
bool flag = true;
for(int l = 0; l < k; l++){
if(G[j][v[l]] == INF){
flag = false;
break;
}
}
if(flag == true){
mayInvite = true;
inviteIndex = j;
break;
}
}
if(needHelp == true) printf("Area %d needs help.\n",i);
else if(mayInvite == true) printf("Area %d may invite more people, such as %d.\n",i,inviteIndex);
else printf("Area %d is OK.\n",i);
}
return 0;
}
搞清楚判断的是G[v[j]][v[l]]不是j和l!
文章浏览阅读2.5k次,点赞6次,收藏4次。jwt.SigningMethodES256 两种类型 *SigningMethodECDSA 和 *SigningMethodHMACjwts := jwt.NewWithClaims(jwt.SigningMethodES256, c) // SigningMethodES256 *SigningMethodECDSA 此类型会报错: key is of invalid type`jwts := jwt.NewWithClaims(jwt.SigningMethodHS256, c) // S
文章浏览阅读1.2k次。近年来,国家对数据中心行业的能耗要求越来越严格,很多地区,不仅包括北方的北京,甚至南方的上海,都要求新建数据中心的PUE在1.3以下。在此背景下,越来越多的有效节能技术被广泛应用,其中影响较大的有间接蒸发制冷技术和液冷服务器。间接蒸发冷技术,在从南方的深圳至北方的内蒙古海拉尔,都能看到它的身影,而这个技术也确实带来了实实在在的PUE值的降低,据厂家计算,在全国任何地方,均可实现PUE小于1.25。一时成为解决PUE问题的苦口良药。之所以说苦口,是因为间接蒸发冷确实有一些让用户难受的自身特点,如果不具备_间接蒸发冷却技术的缺点
文章浏览阅读149次。hive 详细安装教程_hive1.2.x安装
文章浏览阅读60次。深度强化学习是一种结合了深度学习和强化学习的技术,它通过引入神经网络来表示状态、动作和奖励,从而实现更好的模型表现和泛化能力。深度强化学习的核心算法原理包括:策略梯度、动作值、深度Q-Learning和策略梯度与动作值的结合。深度强化学习的具体操作步骤包括:初始化神经网络、初始化策略、初始化学习率、初始化记忆缓存、开始训练、更新策略、更新神经网络和重复步骤。深度强化学习的数学模型公式详细讲解包括策略梯度、动作值、深度Q-Learning和策略梯度与动作值的结合。
文章浏览阅读957次。基于JAXB实现xml与bean的互相转换import java.io.IOException;import java.io.StringReader;import java.io.StringWriter;import javax.xml.bind.JAXBContext;import javax.xml.bind.JAXBException;import javax.xml...._jaxb xml 转 bean 跨层
文章浏览阅读2.1k次。连享会-文本分析与爬虫专题研讨班诚邀助教:连享会-文本分析与爬虫专题这篇教程的内容比较。。。丧心病狂。旨在演示灵活组合 geojson 文件绘制复杂的区域地图。我首先是将 34 个省级的 GEOJSON 文件组合起来绘制了市级中国地图,然后又将 344 个市级的 GEOJSON 文件组合起来绘制了县级中国地图。当然绘制县级和市级中国地图的最好办法是使用之前我提供的 shp 文件。除此之外..._中国县域shp文件
文章浏览阅读1.3k次。搞科研的朋友们每天都离不开电脑!于是,科研界又分为 Windows 派和 Mac 派。要想提高生产力,本人还是想大吼一声:Mac 大法好!看着师弟师妹对着苹果电脑咬牙切齿,恨不得分分钟砸了它;殊不知不是系统不好用,而是我们了解得太少!如何避免在 Mac 上跑 Windows 的尴尬呢?——且听我慢慢道来!为 Mac 正名苹果系统搞科研很稳对于刚接触科研/macOS 的小白同学,不免会发出 mac ...
文章浏览阅读6.1k次,点赞8次,收藏8次。Eclipse的白色背景很刺眼,dark主题黑的看不清,还是豆沙绿看着舒服,但是网上的教程只能做到更改代码区的背景色。eclipse本身没有提供更改包资源管理器背景色的选项,但是我们可以修改plugins文件夹中的css文件来做到。首先定位到X:\eclipse\plugins\org.eclipse.ui.themes_1.2.0.v20170517-0622文件夹,找到CSS文件夹,打..._eclipse更改包区颜色
文章浏览阅读1.5k次。昨天在网上闲逛时无意中听到这首歌,感觉非常棒,到网上搜了一把,找到一些资料:“阿桑的首张专辑《受了点伤》标榜“秋天到了,请尽情悲伤”,很清楚地点出这张专辑的制作企图与产品定位。由于阿桑的嗓音天生沙哑富有磁性,很适合煽起听者的悲伤情绪,因此这张专辑在制作之前,唱片公司内部上上下下毫无疑义的,一致决定作一张‘很悲伤’的唱片。卸下追求流行前卫曲风的包袱,制作的标准只有2个字:“感情”,企图以真实_搜索 阿桑《叶子》
文章浏览阅读426次,点赞2次,收藏4次。你知道的越多,你不知道的越多 点赞再看,养成习惯前言叮当小说网 wap.guxs.netRedis在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在Redis的使用和原理方面对小伙伴们进行360°的刁难。作为一个在互联网公司面一次拿一次offer的面霸(请允许我使用一下夸张的修辞手法),打败了无数竞争对手,每次都只能看到无数落寞的身影失望的离开,略感愧疚,在...
文章浏览阅读4.3k次。Test sites / testing groundsSPI Dynamics (live) – http://zero.webappsecurity.com/Cenzic (live) – http://crackme.cenzic.com/Watchfire (live) – http://demo.testfire.net/Acunetix (live) – http:
文章浏览阅读2.6k次,点赞2次,收藏3次。第1关:MySQL 分页查询本关任务:能分页读取表中数据,针对大数据量进行简单优化。USE Products;#请在此处添加实现代码########## Begin ###########1.分页查询select prod_id from products limit 5,5;#2.用子查询优化分页查询语句select prod_id from products where prod_id >=(select prod_id from products limit 10,1) l_本关任务:能分页读取表中数据,针对大数据量进行简单优化。