PAT甲级 1166 Summit
update202302
for(j = 1; j <= N; j++) 编号从1~N,要记得加上<=
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
int arr[206][206];
int main(void) {int i, j, k, m, n, N, M, K, L, y, z, h;cin>>N>>M;for(i = 0; i < M; i++) {cin>>y>>z;arr[y][z] = arr[z][y] = 1;}cin>>K;for(i = 1; i<=K; i++) {cin>>L;vector<int> v(L);unordered_map<int, int> ump;for(j = 0; j < L; j++) {scanf("%d", &v[j]);ump[v[j]] = 1;}int mr = 9, kk = 9;for(j = 0; j < L; j++) {for(h = j + 1; h < L; h++) {if(arr[v[j]][v[h]]==0) {mr = -9;break;}}if(mr < 0) break;}if(mr < 0) {printf("Area %d needs help.\n", i);continue;}for(j = 1; j <= N; j++) {if(ump[j] == 1) continue;mr = 9;for(h = 0; h < L; h++) {if(arr[j][v[h]]==0) {mr = -9;break;}}if(mr > 0) {kk = -9;break;}}if(kk < 0) {printf("Area %d may invite more people, such as %d.\n", i, j);continue;;}printf("Area %d is OK.\n", i);}return 0;
}
old before
#include<iostream>
#include<vector>
#include<set>
using namespace std;
struct nod {int l, r;};
int main(void) {int i, j, k, m, n, x1, x2, ori;cin>>m>>n;bool arr[209][209] = {false};vector<nod> vt;nod nd;for(i = 0; i < n; i++) {cin>>nd.l>>nd.r;arr[nd.l][nd.r] = arr[nd.r][nd.l] = true;vt.push_back(nd);}cin>>n;for(i = 0; i < n; i++) {cin>>k;set<int> st, st0;vector<int> v, v0;int mr = -9;for(j = 0; j < k; j++) {cin>>x1;v0.push_back(x1);st0.insert(x1);}for(j = 0; j < k; j++) {for(x1 = j+1; x1< k; x1++) {if(arr[v0[j]][v0[x1]]==false){mr = 9;printf("Area %d needs help.\n", i+1);break;}}if(mr > 0) break;}if(mr > 0) continue;int kk = -9;for(j = 1; j <=m; j++) {if(st0.find(j)!=st0.end()) continue;mr = -9;for(x1 = 0; x1 < v0.size(); x1++) {if(arr[v0[x1]][j]==false) {mr = 9; break;}}if(mr < 0) {kk = 9;printf("Area %d may invite more people, such as %d.\n", i+1, j);break;}}if(kk > 0) continue;printf("Area %d is OK.\n", i+1);}return 0;
}
GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT
PAT甲级 1166 Summit相关推荐
- 19年冬季第二题 PAT甲级 1166 Summit (25分)
7-3 Summit (25分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest area ...
- PAT甲级——1166 Summit (25 分)
思路: 模拟,用两位vector表示edge相连关系 然后,看是否两两相连和是否有其他点与其都相连 src // 不需要并查 #include<bits/stdc++.h> using n ...
- PAT 甲级1166(图)Summit (25分)
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...
- 1166 Summit (25 point(s)) PAT甲级
1166 Summit (25 point(s)) 题目 A summit (峰会) is a meeting of heads of state or government. Arranging t ...
- PAT 1166 Summit
1166 Summit (25 分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest ar ...
- 2020年9月PAT甲级满分必备刷题技巧
2020年7月的考试结束了,除了本次的考题更新,短期内不会更新. [7月题目的特点:首次线上考试,没出链表.树相关的模板题,第2到4题背景新颖,大大降低了抄袭历年代码的可能性,可以看作是线上考试的新趋 ...
- PTA Advanced 1166 Summit C++
目录 题目 Input Specification: Output Specification: Sample Input: Sample Output: 领悟 知识补充 代码 题目 A summit ...
- pat甲级考试报名费_PAT(甲级)2019年冬季考试 题解
总结写在前头: 考了字符串.链表(伪链表).图.树.考点比较均衡. 本次考试难度还行,需要较扎实的数据结构底子,对于字符串处理的技巧有一定的要求. 说句题外话,字符串是个重点,主要因为很多人会忽视字符 ...
- 2019年12月PAT甲级满分备考经验
PAT甲级满分备考经验 答题过程 备考经验 答题过程 总得来说,我觉得我幸运,碰上了一次PAT甲级题目相当简单(1085中有190人满分),最终提前一小时交卷,实时排名为35. 我按照1 2 ...
最新文章
- 每日英语:Relationship Repair: 10 Tips for Thinking Like a Therapist
- [armv9]-ARMV9 CCA 机密计算简介
- android默认获取敏感权限
- stop-hbase.sh一直处于等待状态
- K8S安全军规101:对CNCF最佳实践的扩充
- 基于Lock的卖票和生产者消费者案例
- [转载]浅谈敏捷管理在软件项目中应用
- centos配置网络
- 虚拟机VMware镜像下载及安装Linux系统
- 安装rarlinux及问题解决
- flash砸金蛋_砸金蛋flash课件模版-幸运抽奖随机抽题-多媒体交互式flash游戏课件模版...
- 华为认证高级网络工程师(Huawei Certified Senior Network Engineer HCSE)
- Linux内核之——等待队列wait queue
- 有关“A New Adversarial Embedding Method for Enhancing Image Steganography“的理解
- BUCK电源芯片做升压电源的方法(1)
- 《MATLAB编程》例题-画分段函数图像
- Spring注解解析及工作原理、自定义注解
- 服务器响应状态码statusCode
- 如何永久去除CSDN中图片的水印
- 铁头乔:开源社区那些事
热门文章
- 请推荐高校图书馆数据库绩效评价的国外文献
- ViewPager 实现广告页轮播、打造卡片切换、卡片缩放动画
- 怎么查看ubuntu服务器gpu型号,ubuntu查看显卡型号方法有哪些
- Parsing error: Unexpected token
- 时序数据库DolphinDB 在台湾永丰金证券的应用
- 如何注册新加坡lol服务器,lol手游新加坡服怎么登录 新加坡服怎么注册[多图]
- linuxnbsp;下一键移植nbsp;乐蛙/…
- 一个首项大于0的等差数列的前四项的和为26,前四项的积为880,求此数列。
- 给高通收购恩智浦放行,中国这两个产业或许放心
- 如何找回U盘清理了的文件