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!
文章浏览阅读322次,点赞6次,收藏8次。【代码】杭电2041 超级楼梯。_超级楼梯 (杭电2041)比赛题目 题目统计 全部提交时间限制:c/c++ 1000ms,其他语言
文章浏览阅读1.6k次。写在前面数据仓库(Data Warehouse)是一个面向主题的(Subject Oriented)、集成的(Integrated)、相对稳定的(Non-Volatile)、反映历史变化(Time Variant)的数据集合,用于支持管理决策(Decision Making Support)。近年来,随着大数据的应用不断深入,构建企业级数据仓库成为了企业进行精细化运营的一种趋势。从管理者的视角来看,数据仓库是赋能业务并辅助决策的一种工具,从开发者的视角来看,数据仓库是一堆数据模型的集合。数仓开发是一个系_从需求出发建设数仓会有什么问题
文章浏览阅读3.2k次。插入关键字 40 ,按照第 2 种情况将结点分裂,并将关键字 37 上移到父结点,发现父结点 [15、37、44、59] 包含的关键字的个数大于 M ,所以将结点 [15、37、44、59] 分裂为两个结点 [15、37] 和结点 [44、59] ,并将关键字 37 上移到父结点中 [37、59、97] . 父结点包含关键字个数没有超过 M ,插入结束。比如插入关键字 12 ,插入关键字所在的结点的 [10,15] 包含两个关键字,小于 M ,则直接插入关键字 12。B+树插入删除时间复杂度为0(1)_手写b+树
文章浏览阅读82次。在答辩过程中,要充分展示对项目的深入研究和对技术的理解,结合实际案例和数据,清晰阐述项目的创新、可行性和应用价值,回答评委问题时要有条理、准确表达自己的观点。管理员:首页、用户管理、管理员、员工、更多管理、部门管理、 请假申请、人事考勤、公司绩效、奖惩信息、通知公告、员工工资等。员工:首页、更多管理、请假申请、人事考勤、公司绩效、奖惩信息、通知公告、员工工资等。该项目含有源码、论文等资料、配套开发软件、软件安装教程、项目发布教程等。前端技术:JavaScript、VUE.js(2.X)、css3。_基于ssm的企业人力资源管理系统的设计与实现
文章浏览阅读940次,点赞14次,收藏16次。首先根据当前机器人状态选择合适的步态模式(站立。然后根据步态模式生成相应的脚部期望轨迹,)是摆动腿阶段,应该采用另外的。最后更新机器人的控制命令。问题的求解使用第三方库。)是跟摩擦系数有关,_force-and-moment-based model predictive control for achieving highly dynamic
文章浏览阅读358次,点赞8次,收藏8次。如果表达式所计算的值非零,则 CBool函数返回 True;否则返回 False。下面的示例使用 CBool函数将一个表达式转成 Boolean类型。Check = CBool(A = B) 'Check设为 True。Check = CBool(A) 'Check设为 False。B =1 ' 初始化变量。A = 0 '定义变量。
文章浏览阅读2.6k次。ACLLib 的介绍_acllib库
文章浏览阅读1.1w次,点赞6次,收藏34次。通过阅读本篇文章,你可以了解到:UTF-8编码的规则。_utf-8编码
文章浏览阅读2.1k次,点赞3次,收藏38次。文章目录题目描述算法思路算法实现完整代码题目描述 设带有头结点的单链表,设计一个算法,判断它是否中心对称(回文)。算法思路 利用一个栈存放链表前半部分,然后继续检测链表后半部分,与栈中元素比较,判断链表是否中心对称。算法实现 首要问题就是如何找到链表的中间位置。 为此定义两个指针p,q,初始时均指向链表的第一个结点,然后当指针不空时循环向后同步移动:指针p每次向后移动一个结点,指针q每次向后移动两个结点。那么p,q所指向的结点位置如下面表格中所示:p12345…_判断单链表节点是否中心对称
文章浏览阅读1.7k次。c#实现OPC UA客户端连接kepware_kepserve
文章浏览阅读5.9k次,点赞3次,收藏20次。什么是UEFIShellUEFIShell是一种特殊对待UEFI_APPLICATION。提供用户和UEFI系统之间的一个接口。它有很强大的功能,但是正常启动计算机系统时,不会用到UEFIShell,只有当系统启动出现问题,或者用户就是喜欢UEFIShell(就像博主我一样,深深的爱着UEFI),主动进入UEFIShell来对计算机系统进行配置,那么就到了UEFIShell大显身手,炫酷吊炸天的时候来了。玩儿转UEFIShellShell提供了丰富的内部命令。可以分为几大类:调试..._uefi shell能用来解决什么
文章浏览阅读4.3k次,点赞3次,收藏6次。查看本章节查看作业目录需求说明:使用 JavaScript 中的 Date 对象,在页面上显示一个万年历。选择不同的年份和月份,在页面中显示当前月的日历实现思路:在页面中添加两个 <select> 标签,用来显示年份和月份;同时添加两个 <ul> 标签,一个用来显示星期,另一个用来显示日期在 JavaScript 脚本中动态添加年份和月份,获取当前日期的年份和月份,显示到 <select> 标签上根据 <select> 标签上显_javascript select填充月份