7-3 Summit (25分)

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.
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int   mp[209][209],vis[209]; 
bool  checkALL(  vector<int> &v ){
	  int isideal = 1 ;
	  for( int i=1 ; i<v.size();i++ ){
	  	   for( int j=i+1;j<v.size();j++){
	  	        if( !mp[ v[i] ][ v[j] ] ){
	  	             isideal = 0;
					 break; 	
				} 	    	
		   }
		   if( !isideal )
		       break;
	  }
	  if( !isideal )
	      return false;
	  return true;
}

int find(int n , vector<int>&v){
	for( int i=1;i<=n;i++ ){
		 if( vis[i] )
		     continue;
		 vector<int> vv = v;
		 vv.push_back( i );
		 if( checkALL( vv ) )
		     return i;
	} 
	return -1;
}
int main(void){
	int n,m,a,b;
	cin>>n>>m;
	for( int i=1;i<=m;i++){
		 cin>>a>>b;
		 mp[a][b] = 1 ;
		 mp[b][a] = 1 ;
	}
	int k,l;
	cin>>k;
	for( int i=1;i<=k;i++){
	     cin>>l;
		 vector<int> v(l+1);
		 fill( vis , vis +209,0);
		 for( int j=1;j<=l;j++){
		 	  cin>>v[j];
		 	  vis[ v[j] ] =1;
		 }
		 if(  !checkALL( v ) )
		      cout<<"Area "<<i<<" needs help."<<endl; 
	     else {
	     	 int small = find(n, v );
			 if(  small ==-1 )
			      cout<<"Area "<<i<<" is OK."<<endl;
			 else cout<<"Area "<<i<<" may invite more people, such as "<<small<<"."<<endl; 
		 }
	}	
	return 0;
}

 

已标记关键词 清除标记
相关推荐
课程简介: 历经半个多月的时间,Debug亲自撸的 “企业员工角色权限管理平台” 终于完成了。正如字面意思,本课程讲解的是一个真正意义上的、企业级的项目实战,主要介绍了企业级应用系统中后端应用权限的管理,其中主要涵盖了六大核心业务模块、十几张数据库表。 其中的核心业务模块主要包括用户模块、部门模块、岗位模块、角色模块、菜单模块和系统日志模块;与此同时,Debug还亲自撸了额外的附属模块,包括字典管理模块、商品类模块以及考勤管理模块等等,主要是为了更好地巩固相应的技术栈以及企业应用系统业务模块的开发流程! 核心技术栈列表: 值得介绍的是,本课程在技术栈层面涵盖了前端和后端的大部常用技术,包括Spring Boot、Spring MVC、Mybatis、Mybatis-Plus、Shiro(身份认证与资源授权跟会话等等)、Spring AOP、防止XSS攻击、防止SQL注入攻击、过滤器Filter、验证码Kaptcha、热部署插件Devtools、POI、Vue、LayUI、ElementUI、JQuery、HTML、Bootstrap、Freemarker、一键打包部署运行工具Wagon等等,如下图所示: 课程内容与收益: 总的来说,本课程是一门具有很强实践性质的“项目实战”课程,即“企业应用员工角色权限管理平台”,主要介绍了当前企业级应用系统中员工、部门、岗位、角色、权限、菜单以及其他实体模块的管理;其中,还重点讲解了如何基于Shiro的资源授权实现员工-角色-操作权限、员工-角色-数据权限的管理;在课程的最后,还介绍了如何实现一键打包上传部署运行项目等等。如下图所示为本权限管理平台的数据库设计图: 以下为项目整体的运行效果截图: 值得一提的是,在本课程中,Debug也向各位小伙伴介绍了如何在企业级应用系统业务模块的开发中,前端到后端再到数据库,最后再到服务器的上线部署运行等流程,如下图所示:
©️2020 CSDN 皮肤主题: 程序猿惹谁了 设计师:白松林 返回首页