2019冬季PAT甲级第三题
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
set<int>v[];
int a[];
int vis[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
for(int i=;i<=m;++i){
int x,y;
cin>>x>>y;
v[x].insert(y);
v[y].insert(x);
}
int k;
cin>>k;
for(int i=;i<=k;++i){
int num;
cin>>num;
if(num==){
cout<<"Area "<<i<<" needs help.";
cout<<"\n";
continue;
}
for(int j=;j<=num;++j)
cin>>a[j];
int flag=;
for(int k=;k<=num;++k){
for(int j=;j<=num;++j){
if(k==j)
continue;
if(!v[a[k]].count(a[j])){
flag=;
}
}
}
if(flag){
cout<<"Area "<<i<<" needs help.";
cout<<"\n";
continue;
}
memset(vis,,sizeof(vis));
for(int j=;j<=num;++j){
for(auto it:v[a[j]])
++vis[it];
}
int ans=;
for(int j=;j<=n;++j)
if(vis[j]==num){
ans=j;
break;
}
if(ans){
cout<<"Area "<<i<<" may invite more people, such as "<<ans<<".";
cout<<"\n";
continue;
}
cout<<"Area "<<i<<" is OK.";
cout<<"\n";
}
return ;
}
2019冬季PAT甲级第三题的更多相关文章
- 2019冬季PAT甲级第四题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct node{ ...
- 2019冬季PAT甲级第二题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct{ int ...
- 2019冬季PAT甲级第一题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ][]; ][]; ]; string ...
- 2019秋季PAT甲级_备考总结
2019 秋季 PAT 甲级 备考总结 在 2019/9/8 的 PAT 甲级考试中拿到了满分,考试题目的C++题解记录在这里,此处对备考过程和考试情况做一个总结.如果我的方法能帮助到碰巧点进来的有缘 ...
- PAT甲级训练刷题代码记录
刷题链接:https://www.patest.cn/contests/pat-a-practise 1001 #include <iostream> #include <stdio ...
- 2019秋季PAT甲级_C++题解
2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Fore ...
- PAT甲级 Dijkstra 相关题_C++题解
Dijkstra PAT (Advanced Level) Practice Dijkstra 相关题 目录 <算法笔记>重点摘要 1003 Emergency (25) <算法笔记 ...
- PAT甲级 散列题_C++题解
散列 PAT (Advanced Level) Practice 散列题 目录 <算法笔记> 重点摘要 1002 A+B for Polynomials (25) 1009 Product ...
- PAT甲级 二叉树 相关题_C++题解
二叉树 PAT (Advanced Level) Practice 二叉树 相关题 目录 <算法笔记> 重点摘要 1020 Tree Traversals (25) 1086 Tree T ...
随机推荐
- shell循环结构解析:for/while/case
1.for循环结构 for var in item1 item2 ... itemN do command1 command2 ... commandN done 例如,顺序输出当前列表中的数字: # ...
- [SDOI2012] Longge的问题 - 欧拉函数
求 \(\sum\limits_{i=1}^{n}gcd(i,n)\) Solution 化简为 \(\sum\limits_{i|n}^{n}φ(\dfrac{n}{i})i\) 筛出欧拉函数暴力求 ...
- loj6278 数列分块入门题2
题意:支持区间加,询问区间中元素排名 维护两个域.一个域维护原序列,一个域维护快内排序序列. 每次修改后更新快内排序序列. 修改时O(sqrt(n)log(sqrt(n))) 询问时O(sqrt(n) ...
- Linux常用命令: zip、unzip 压缩和解压缩命令
zip基本用法是: zip [参数] [打包后的文件名] [打包的目录路径] 常用参数: -a 将文件转成ASCII模式 -F 尝试修复损坏的压缩文件 -h 显示帮助界面 -m 将文件压缩之后,删除源 ...
- 3行java代码实现百度站长主动推送
个人博客 地址:http://www.wenhaofan.com/article/push-link-seo 介绍 当网站新增了一个网页之后,此时这个网页是不能够立马被百度收录的,如果想以最快的速度被 ...
- malloc函数动态分配内存
#include <stdio.h> #include <stdlib.h> //malloc free #include <windows.h> //sleep ...
- Redis到底是多线程还是单线程?线程安全吗,还需要加锁吗?
0. redis单线程问题 单线程指的是网络请求模块使用了一个线程(所以不需考虑并发安全性),即一个线程处理所有网络请求,其他模块仍用了多个线程. 1. 为什么说redis能够快速执行 (1) 绝大部 ...
- 洛谷P1068 分数线划定
https://www.luogu.org/problem/P1068 #include<bits/stdc++.h> using namespace std; struct Can { ...
- 《深入理解Java虚拟机》读书笔记七
第八章 虚拟机字节码执行引擎 1.运行时栈帧结构 概述: 栈帧是用于支持虚拟机进行方法调用的和方法执行的数据结构,他是虚拟机运行时数据区中的虚拟机栈的栈元素,栈帧存储了方法的局部变量,操作数栈,动态连 ...
- centos7使用jenkins启动找不到模块
问题: 在jenkins上启动pycharm项目报:ModuleNotFoundError: No module named 'wanwenyc' 其中‘wanwenyc’为pycharm工程项目路径 ...