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)N (≤ 200)N(≤200), the number of heads in the summit, and MMM, the number of friendship relations. Then MMM lines follow, each gives a pair of indices of the heads who are friends to each other. The heads are indexed from 111 to NNN.
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.
类似于最大团PAT1142 Maximal Clique
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int G[N][N];
int n, m;
int arr[N];
unordered_set<int> st;
int judge(int l){for(int i = 0; i < l; i++){for(int j = i+1; j < l; j++){if(G[arr[i]][arr[j]] == 0) return -1;}}//have edgefor(int i = 1; i <= n; i++){if(!st.count(i)){bool flag = false;for(int j = 0; j < l; j++){int v = arr[j];if(!G[v][i]) flag = true;}if(!flag) return i;}}return 0;
}
int main(){int k, l, x, u, v;scanf("%d%d", &n, &m);memset(G, 0, sizeof G);while(m--){scanf("%d%d", &u, &v);G[u][v] = 1;G[v][u] = 1;}scanf("%d", &k);for(int i = 1; i <= k; i++){st.clear();scanf("%d", &l);for(int j = 0; j < l; j++){scanf("%d", &arr[j]);st.insert(arr[j]);}int res = judge(l);if(res == 0){printf("Area %d is OK.\n", i);}else if(res == -1){printf("Area %d needs help.\n", i);}else{printf("Area %d may invite more people, such as %d.\n", i, res);}}return 0;
}
7-3 Summit (25分)相关推荐
- 7-3 Summit (25分)
7-3 Summit (25分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest area ...
- 19年冬季第二题 PAT甲级 1166 Summit (25分)
7-3 Summit (25分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest area ...
- 1166 Summit (25 分) PAT
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...
- PAT A1162 7-3 Summit (25分)
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...
- PAT 甲级1166(图)Summit (25分)
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...
- PAT (Advanced Level) Practice 1166 Summit (25 分)
题目 因为只是判断是否是直接相连,所以觉得直接用暴力模拟,而且数据范围也很小.果然,许久不练题,A题的效率都下降了.不过,练题真的是打发时间的好途径. #include <bits/stdc++ ...
- PAT甲级——1166 Summit (25 分)
思路: 模拟,用两位vector表示edge相连关系 然后,看是否两两相连和是否有其他点与其都相连 src // 不需要并查 #include<bits/stdc++.h> using n ...
- 12门课100分直博清华!这份成绩单冲上热搜,但学霸小伙也曾考过25分
点击上方"视学算法",选择加"星标"或"置顶" 重磅干货,第一时间送达 金磊 明敏 发自 凹非寺 量子位 报道 | 公众号 QbitAI 一 ...
- PTA 7-3 旅游规划 (25分)(双权值Dijkstra最短路)
7-3 旅游规划 (25分) 有了一张自驾旅游路线图,你会知道城市间的高速公路长度.以及该公路要收取的过路费.现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径.如果有若干条路 ...
最新文章
- AI 基础:Python 简易入门
- android 判断对象,Android网络判断知识小结
- 致敬百年南开!南开大学作译者30本必读经典著作
- k8s包管理器helm_K8S 实战(十九)| K8S 包管理 Helm
- 关于代码审查,那些你不曾关注的细节
- 常见的协议号和端口号
- Ubuntu常用软件大全
- matlab经验正交eof,经验正交函数分解(EOF).pdf
- 微信计数器|微信自动加好友|微信自动通过好友|微信HOOK|微信静默清粉
- swfupload 无法加载_文件上传插件SWFUpload的使用指南
- RGB/YUV/YIQ 颜色空间
- 【MySQL】测试题01
- 盘点4种微信营销如何快速吸粉的方法
- Java高频重点面试题,看这一篇就够了。
- jupyter notebook第七章seaborn库的一些案例分析加相关函数的解析
- 什么是人工智能?人工智能的本质是什么?
- Unity通过协程实现回合制战斗
- 电子商务安全欺诈预防市场现状研究分析-
- 蓝牙设备删除失败处理方式
- 虚拟机之间文件的传输
热门文章
- 关于达梦数据库的一些浅显思考
- 金山网络不是金山的,而是腾讯的:小卒过河顶大车
- 数据恢复:救命!在文件夹里不小心点了ctrl+Z,文件丢失
- 1-6 Springboot拦截器 Interceptor 通过重写addInterceptors方法添加一个HandlerInterceptor对象
- Win10电脑流畅运行《极品飞车3:热力追踪》游戏的方法
- 电气自动化专业和计算机专业哪一个好学,2021自动化和电气工程哪个好 选什么专业好...
- 基于Pytorch+CNN实现英文文本语义相似度
- 冷眼看待360与QQ之争
- 使用 Java(SpringMVC)+MySQL 实现基于微信小程序的停车管理系统【100011100】
- Python爬虫----网页下载器和urllib2模块及对应的实例