pat2020春季 7-2 The Judger (25分)
#include<iostream>
#include<vector>
#include<set>
using namespace std;
bool islegal[11];//判断该玩家是否出局
vector<vector<int>> book;//存储所有玩家给出的答案
set<int> legal, hasvisited;//统计合法数,已经出现过的数字
int main(){int n, m;scanf("%d %d", &n, &m);hasvisited.insert(n);hasvisited.insert(m);legal.insert(abs(m-n));scanf("%d %d", &n, &m);book.resize(n+1);for(int i = 1; i <= n; i++){book[i].resize(m+1);for(int j = 1; j <= m; j++){scanf("%d", &book[i][j]);}}fill(islegal, islegal+11, true);//第i局 第j玩家for(int i = 1; i <= m; i++){vector<int> isout;//存储每回合出具玩家for(int j = 1; j <= n; j++){if(islegal[j] == false) continue;if(hasvisited.find(book[j][i]) != hasvisited.end() || legal.find(book[j][i]) == legal.end()){//不合法isout.push_back(j);islegal[j] = false;}for (auto it = hasvisited.begin(); it != hasvisited.end(); it++) {legal.insert(abs(*it - book[j][i]));}hasvisited.insert(book[j][i]);}for(int j = 0; j < isout.size(); j++){printf("Round #%d: %d is out.\n", i, isout[j]);}}vector<int> anss;for(int i = 1; i <= n; i++){if(islegal[i] == true){anss.push_back(i);}}if(anss.size() == 0){printf("No Winner.\n");}else{printf("Winner(s): ");for(int i = 0; i < anss.size(); i++){if(i != 0) printf(" ");printf("%d", anss[i]);}}return 0;
}
pat2020春季 7-2 The Judger (25分)相关推荐
- 19年春季第二题 PAT甲级 1157 Anniversary(25 分)
英文题目 Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the cel ...
- 12门课100分直博清华!这份成绩单冲上热搜,但学霸小伙也曾考过25分
点击上方"视学算法",选择加"星标"或"置顶" 重磅干货,第一时间送达 金磊 明敏 发自 凹非寺 量子位 报道 | 公众号 QbitAI 一 ...
- PTA 7-3 旅游规划 (25分)(双权值Dijkstra最短路)
7-3 旅游规划 (25分) 有了一张自驾旅游路线图,你会知道城市间的高速公路长度.以及该公路要收取的过路费.现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径.如果有若干条路 ...
- PTA 03-树1 树的同构 (25分)
题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/711 5-3 树的同构 (25分) 给定两棵树T1和T2.如果T1可以通过若干次左右 ...
- 【PAT (Advanced Level) Practice】1051 Pop Sequence (25 分)
1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the order ...
- 【PAT (Advanced Level) Practice】1093 Count PAT‘s (25 分)
1093 Count PAT's (25 分) The string APPAPT contains two PAT's as substrings. The first one is formed ...
- 【PAT (Advanced Level) Practice】1149 Dangerous Goods Packaging (25 分)
1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not ...
- 7-29 修理牧场 (25 分)
7-29 修理牧场 (25 分) 农夫要修理牧场的一段栅栏,他测量了栅栏,发现需要N块木头,每块木头长度为整数L i 个长度单位,于是他购买了一条很长的.能锯成N块的木头,即该木头的长度是L ...
- 7-18 银行业务队列简单模拟 (25 分)
7-18 银行业务队列简单模拟 (25 分) 设某银行有A.B两个业务窗口,且处理业务的速度不一样,其中A窗口处理速度是B窗口的2倍 -- 即当A窗口每处理完2个顾客时,B窗口处理完1个顾客.给定到达 ...
- 5-35 城市间紧急救援 (25分) pat 数据结构
题目连接 https://pta.patest.cn/pta/test/15/exam/4/question/862 5-35 城市间紧急救援 (25分) 作为一个城市的应急救援队伍的负责人,你有 ...
最新文章
- 对数组中的数字 1 和 2 进行排序,使得数字 1、2 分别位于前、后部分
- 调查报告:工人们并不担心将来会被AI取代
- 量子计算机计算时间复杂度,量子计算复杂性理论综述.PDF
- PHP异常处理类(文件上传提示)
- 如何在python中显示电脑中的图片-python在终端里面显示一张图片
- torch.flatten()函数
- AI:IPPR的数学表示-CNN稀疏结构进化(Mobile、xception、Shuffle、SE、Dilated、Deformable)
- 一张大图片有多个小图片
- [算法] 麻将序数牌组合方案
- 知识图谱论文阅读【十二】【KDD2020】 使用贝叶斯图卷积神经网络推荐精确和多样化项目的框架【看不懂,待续】
- 如何转换并压缩png格式图片
- 苹果cmsv10精仿好看的挖片网免费自适应简约模板
- 文本相似度的方法对比
- 语音识别语言模型和拼音字典文件制作
- mp3转wav,详细方法介绍
- 快乐数-判断一个数字是否是快乐数
- PMI是什么参数在LTE中??和RI,CQI怎么作用的??
- 富士相机设置传原图_富士X-S10相机传图必看!原创完美解决PC互传图片问题
- 微信小程序:wx.createInnerAudioContext的使用
- html 查看excel表格,html展示excel表格数据-html读取本地excel文件并展示