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 ...
最新文章
- 7 1学会使用 Node 编写简单的前端应用
- 工作方法及总结(给自己的忠告)
- Javascript基础之-Promise
- char类型和Unicode编码
- Tomcat控制台输出到文件
- 【绝对干货】TEASER前传之QUASAR:基于四元数的存在外点Wahba问题的可证明最优解
- 苹果春季新品发布会来了:将推iPhone13 Pro系列紫色版
- NSX产品许可介绍( 适用于vSphere 6.2.x,6.3.x和6.4.x的VMware NSX的产品产品(2145269))
- zabbix简介及部署
- Exchange2010部署 配置证书
- Getway 中predicates: - Query=x 标签作用
- Ubuntu下搭建C/C++开发环境
- Power Analysis估算样本容量
- 60后文风 or 90后文风,哪一款是你的真爱?| 文末有彩蛋
- CRM对接企业微信日程快速实现提醒功能
- HCIA-5G网络架构及关键技术
- 各种 PNG图片压缩对比分析
- tcl基本语法:中括号[ ]、大括号{ }、双引号“ ”
- Dalvik--Android专属Java虚拟机
- 国内外深度学习开放数据集下载集合(值得收藏,不断更新)
热门文章
- vue中纯前端实现滑动图片验证的方式
- html网页设计期末大作业——酒庄网页设计实例(5页)
- Maven安装配置全教程
- 数据库的隔离级别介绍
- 采集到竞争对手公司信息的10个经典方法
- 计算机论文写作提纲怎么写,计算机算法论文提纲 计算机算法论文大纲如何写...
- 【Vivado那些事儿】Vivado中运行时出现visual c++运行错误的解决办法
- mysql 闪回删除记录_mysql5.7 闪回数据(update delete insert)
- opencv 安装 opencv_contrib 出现的几个问题和解决方法
- 微人事学习笔记(持续更新)