PAT甲级真题1166
思路:判断是否为团,是的话看能否加入一个顶点
代码:
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;
const int N = 300;
bool st[N];
int g[N][N];int main()
{int n,m;scanf("%d%d", &n, &m);while (m -- ){int x,y;scanf("%d%d", &x, &y);g[x][y] = g[y][x] = true;}scanf("%d", &m);for(int t = 1; t <= m; t++){int cnt ;memset(st, 0, sizeof st);scanf("%d", &cnt);while(cnt-- ){int x;scanf("%d", &x);st[x] = true;}bool is_clique = true;for(int i = 1; i <= n; i++)for(int j = i + 1; j <= n; j++)if(st[i]&&st[j]&&!g[i][j])is_clique = false;if(!is_clique){printf("Area %d needs help.\n",t);}else{int id = 0;for(int i = 1; i <= n; i++){if(!st[i]){bool is_join = true;for(int j = 1; j <= n; j++)if(st[j]&&!g[i][j]){is_join = false;break;}if(is_join){id = i;break;}}}if(id) printf("Area %d may invite more people, such as %d.\n", t, id);else printf("Area %d is OK.\n", t);}}}
PAT甲级真题1166相关推荐
- PAT甲级真题 1018 A+B in Hogwarts--python解法
PAT甲级真题 1018 A+B in Hogwarts 提交:2638 通过:1559 通过率:59% If you are a fan of Harry Potter, you would kno ...
- PAT甲级真题目录(按题型整理)(转自柳神)
转载自:https://www.liuchuo.net/archives/2502?tdsourcetag=s_pcqq_aiomsg 最短路径 1003. Emergency (25)-PAT甲级真 ...
- 1166 Summit – PAT甲级真题
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...
- 【PAT甲级真题整理五】1121~1155
终于考完了qaq把最后一堆也整理出来了 目录 1121 Damn Single(25)set.map的使用 1122 Hamiltonian Cycle(25)哈密顿回路 1123 Is It a C ...
- PAT甲级真题 1011 World Cup Betting (20分) C++实现
题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...
- 1131. Subway Map (30)-PAT甲级真题 (DFS or 堆优化dij or SPFA)
题意 给出地铁线路数n,分别给出每条线的站点数m,再依次列出站点id.然后询问k次从启点sv到终点ev的最短路径,如果最短路径相同,要求换乘最少的路径.最后按条件输出. 思路 1.用unordered ...
- 「PAT甲级真题解析」Advanced Level 1009 Product of Polynomials
PAT (Advanced Level) Practice 1009 Product of Polynomials 如果对你有帮助,要点个赞让我知道喔~ 文章目录 问题分析 完整步骤描述 伪代码描述 ...
- 【PAT甲级真题整理三】1061~1090
目录 1061 Dating(20)字符串处理 1062 Talent and Virtue(25)排序 1063 Set Similarity(25)set的使用 1064 Complete Bin ...
- 1040. Longest Symmetric String (25)-PAT甲级真题
Given a string, you are supposed to output the length of the longest symmetric sub-string. For examp ...
最新文章
- UITableViewCell 左侧滑动删除按钮 添加图片 (不完美解决)
- JavaScript 异步编程--Generator函数、async、await
- GAN生成对抗网络-PIX2PIXGAN原理与基本实现-图像翻译09
- Eclipse - CDT使用GDB调试C++的问题-无源文件命名(No source file named)
- WPF 实现3D翻转倒计时控件~
- 查看mysql数据库的死锁日志_【MySQL】mysql死锁以及死锁日志分析
- 清朝神秘女科学家,在国外火了200多年,我却对她一无所知…
- 软件测试测试用例编写 不超过7步骤_教你快速编写一个合格的测试用例!
- [置顶] 手机通过socket控制电脑关机,重启,注销等功能
- syslog工具_INAV:一款专用的日志审查导航工具
- 研究生英语面试常见问题及回答
- 迷宫 动画 java_Java实现可视化迷宫
- 台式机电源相关参数说明
- html怎么改变li前面的点,CSS定义li前面的小点样式
- linux的cut命令详解
- win7系统笔记本架设无线热点(AP)
- 用Excel PS 汽车人标志
- 【故障处理】ORA-12545: Connect failed because target host or object does not exist
- Google浏览器提交表单不能执行submit()事件,IE居然可以
- HTC Desire HD 刷机(变砖补救)
热门文章
- 基于Elman神经网络的负荷预测研究
- 【Cloudaily】Elastic Stack 5.2.0 版本发布,Uber免费开放全球20亿行程数据
- JavaFX开发桌面,移动端,嵌入式权威指南(一)—— JavaFX桌面入门小项目
- SCI论文类型及写作结构分析
- 妙控2代鼠标用于Windows系统注册表修改方法
- 南京邮电大学汇编语言程序设计实验一:汇编语言语法练习与代码转换
- NumberFormat类、BigInteger类和BigDecimal类-JAVA
- 微信浏览器不支持下载文件或应用解决方案--跳转到默认浏览器打开
- Spring——spring单例模式的线程安全
- 『深圳』在深圳,做个没故事的人