排位赛1-A Cow Gymnastics

题目

In order to improve their physical fitness, the cows have taken up gymnastics! Farmer John designates his favorite cow Bessie to coach the N other cows and to assess their progress as they learn various gymnastic skills. In each of K practice sessions (1≤K≤10), Bessie ranks the N cows according to their performance (1≤N≤20). Afterward, she is curious about the consistency in these rankings. A pair of two distinct cows is consistent if one cow did better than the other one in every practice session.
Help Bessie compute the total number of consistent pairs.

题意

有N头奶牛进行了K轮体操比赛,现在得到了这K轮比赛的结果,如果一头奶牛在每一轮比赛中排名都比另一头奶牛高则这两头奶牛是一致的(准确翻译不知道是什么),问有多少对奶牛是一致的。

解法

因为K和N都很小,所以我们可以直接枚举两头牛再比较它们每轮比赛的结果来判断它们是否一致。

代码:

#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int k,n,x,ans,a[20][30];
bool flag;int main()
{scanf("%d%d",&k,&n);for (int i=1;i<=k;i++) {for (int j=1;j<=n;j++) {scanf("%d",&x);a[i][x]=j;}}for (int i=1;i<n;i++) {for (int j=i+1;j<=n;j++) {flag=true;for (int z=1;z<=k;z++) {if (a[z][i]>a[z][j]) flag=false;}if (flag) ans++;flag=true;for (int z=1;z<=k;z++) {if (a[z][i]<a[z][j]) flag=false;}if (flag) ans++;}}printf("%d",ans);return 0;
}

排位赛1-A Cow Gymnastics相关推荐

  1. 排位赛一 A Cow Gymnastics

    题目 为了提高健康水平,奶牛们开始进行体操训练了!Farmer John 选定了他最喜爱的奶牛 Bessie 来执教其他 N 头奶牛,同时评估她们学习不同的体操技术的进度. K 次训练课的每一次,Be ...

  2. A.Cow Gymnastics 奶牛体操

    GDUT 2020寒假训练 排位赛一 A 原题链接 A. Cow Gymnastics 题目 描述 In order to improve their physical fitness, the co ...

  3. Cow Gymnastics//队列//排位1

    Cow Gymnastics//队列//排位1 题目 In order to improve their physical fitness, the cows have taken up gymnas ...

  4. 2020 GDUT Rating Contest I A. Cow Gymnastics

    A. Cow Gymnastics 链接 题目描述 有n头牛一起参加了k次比赛,给出k次比赛的排名,问共有几组牛满足 其中一头牛每次比赛都比另一头厉害. 题目分析 由于数据量比较小(1<=k&l ...

  5. 洛谷刷题C语言:陶瓷项链、Cow Gymnastics B、Where Am I? B、Hello, 2020!、SIR 模型

    记录洛谷刷题C语言 一.[NOI2000] 瓷片项链 题目描述 原始部落用一种稀有的泥土烧制直径相同的圆瓷片并串成项链,串的时候沿瓷片的直径方向顺次连接,瓷片之间没有空隙也不重叠,一条项链至少由一个瓷 ...

  6. 2020 GDUT Rating Contest I (Div. 2) A.Cow Gymnastics

    来源 codeforces 2020 GDUT Rating Contest I (Div. 2) 题目: A. Cow Gymnastics In order to improve their ph ...

  7. P5831 [USACO19DEC]Cow Gymnastics B

    P5831 [USACO19DEC]Cow Gymnastics B - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) #include<bits/stdc++.h>usi ...

  8. 2020寒假集训排位赛 Cow Gymnastics 题解(思维)

    专题链接:https://codeforces.com/group/5yyKg9gx7m/contest/269717/problem/A 思路 这道题乍一看没什么思路,但经过观察可以发现,如果两头牛 ...

  9. Cow Gymnastics

    题目描述 为了提高健康水平,奶牛们开始进行体操训练了!Farmer John 选定了他最喜爱的奶牛 Bessie 来执教其他 N 头奶牛,同时评估她们学习不同的体操技术的进度. K 次训练课的每一次, ...

最新文章

  1. 将FeatClass属性表高效率转换成DataTable
  2. 微信小程序之设置不同的顶部导航栏名称
  3. LeetCode-剑指 Offer 03. 数组中重复的数字
  4. Cocos2d-x内存管理研究二
  5. css3文字一行或多行展示,多余文字省略号(学习)超出隐藏
  6. css垂直水平居中的整理
  7. Android笔记 theme主题
  8. centos7.6(腾讯云)开放端口及配置腾讯云安全组
  9. redis实现周边景点由近到远排序
  10. 台达变频器485通讯接线图_三菱PLC 与台达VFD-L 变频器通讯(RS485)程序
  11. springboot集成快递100实现查询快递,面单打印;面单取消
  12. 天赐转债,强联转债,再22转债上市价格预测
  13. 微信小程序 data命名不能大写
  14. 网络安全威胁的主要内容
  15. Win10+vs2017跑yolov3
  16. SharePoint Silverlight Clock 时钟
  17. 【青云志】青立方Qing³ 超融合系统发布
  18. ES集群规划、集群搭建、集群管理
  19. 【React+ts】从零开始搭建react函数式组件+router+redux+less+sass+axios反向代理+antd(保姆式教学)
  20. 计算机局域网组建摘要,毕业设计论文-小型局域网的组建计算机网络技术.doc

热门文章

  1. FPGA----ZCU106基于axi-hp通道的pl与ps数据交互(全网唯一最详)
  2. 浅谈企业的数字化转型
  3. 发票识别 python_增值税发票识别系统(OCR System of Invoice)
  4. 低代码开发平台对于企业IT架构的作用
  5. BCG 各控件使用说明
  6. Android性能调优:App启动速度优化
  7. ShareSDK关于微信分享问题
  8. php面向对象之tian,php之面向对象
  9. Attention专场——(2)Self-Attention 代码解析
  10. 宏碁欲做行业老大 华硕推“巨狮计划”