来源 codeforces 2020 GDUT Rating Contest I (Div. 2)
题目:
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.

Input
The first line of the input file contains two positive integers K and N. The next K lines will each contain the integers 1…N in some order, indicating the rankings of the cows (cows are identified by the numbers 1…N). If A appears before B in one of these lines, that means cow A did better than cow B.

Output
Output, on a single line, the number of consistent pairs.

Example
inputCopy
3 4
4 1 2 3
4 1 3 2
4 2 1 3
outputCopy
4
Note
The consistent pairs of cows are (1,4), (2,4), (3,4), and (1,3).

题意:计算有几对奶牛满足其中一只永远比另一只好。
思路:可以理解为图,每次practice中如果a牛>b牛,就理解为多一条a到b的单向路径,另开一二维数组b,b[i][j]表示i到j几条路径,如果刚好等于k,说明始终i牛大于j牛,n在20以内,直接用Floyd解。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
int n,K,a[30][30],b[30][30],ans;int main()
{cin>>K>>n;for (int i=1;i<=K;i++)for (int j=1;j<=n;j++)scanf("%d",&a[i][j]);for (int i=1;i<=K;i++){for (int j=1;j<=n;j++){for (int k=j+1;k<=n;k++)b[a[i][j]][a[i][k]]++;}}for (int i=1;i<=n;i++)for (int j=1;j<=n;j++)if (b[i][j]>=K) ans++;cout<<ans;return 0;
}

2020 GDUT Rating Contest I (Div. 2) A.Cow Gymnastics相关推荐

  1. 2020 GDUT Rating Contest I (Div. 2) A - Cow Gymnastics 题解

    好吧--是时候补一下题解了 原题 题目大意 给出n只牛,k次排序,如果有一只牛一直比另外一只牛更前算作一对,输出一共有多少对. 题目分析 水题(数据规模小),一开始初始化全部都可以,然后一个个删去就行 ...

  2. 2020 GDUT Rating Contest II (Div. 2) A. Fence Planning

    来源 codeforces 2020 GDUT Rating Contest II (Div. 2) CF链接 题目: Farmer John's N cows, conveniently numbe ...

  3. 2020 GDUT Rating Contest III (Div. 2) B - Loan Repayment 题解

    原题 题目大意 给出NNN,KKK,MMM,假定已经给了GGG加仑奶,定义N−GX\frac{N-G}{X}XN−G​为YYY,YYY最小为MMM,在KKK天后至少给NNN加仑奶,求最大的XXX. 题 ...

  4. 2020 GDUT Rating Contest III (Div2)

    2020 GDUT Rating Contest III (Div2) A Wormhole Sort 题意: 给出N个打乱顺序的数,和M条边(a,b,c)表示在a位置的数可以和在b位置的数交换,这条 ...

  5. 2020 GDUT Rating Contest I A. Cow Gymnastics

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

  6. 2020 GDUT Rating Contest III H. Photoshoot

    H. Photoshoot 链接 题目描述 有n头牛,他们的序号从为1-n,现在他们按一定顺序排好,给出每对相邻的两头牛的序号之和,求出牛现在的序号. 题目分析 因为确定其中一头牛的序号,就可以得出所 ...

  7. 2019 GDUT Rating Contest I : Problem H. Mixing Milk

    题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...

  8. 2019 GDUT Rating Contest II : Problem G. Snow Boots

    题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...

  9. 2019 GDUT Rating Contest II : A. Taming the Herd

    题面: A. Taming the Herd Input file: standard input Output file: standard output Time limit: 1 second Me ...

最新文章

  1. 清华朱文武团队斩获NIPS 2018 AutoML挑战赛亚军,高校排名第一
  2. [转]Entity Framework 异常: ‘OFFSET‘ 附近有语法错误。\r\n在 FETCH 语句中选项 NEXT 的用法无效
  3. android+ip+rule+策略路由,策略路由以及使用 ip route , ip rule , iptables 配置策略路由实例...
  4. 学习记录之Focal loss
  5. 小酌重构系列[19]——分解大括号
  6. 分析:windows下cmd默认的编码是ASCII编码 ,windows的中文环境下编码是GBK 方法一:在保存输出流保存的时候做一个对文字GBK编码,在输出到文件 如下 [python] view
  7. JavaScript实现复选框的全选/全不选和批量选择
  8. Markdown案例
  9. case when then的用法-leetcode交换工资
  10. 数据结构与算法(Python)第三天
  11. MySQL 数据库导出
  12. Linux下常用操作汇总
  13. 企业微信(WeCoom)私有化客户端Api解决方案
  14. 【Visio】 windows Visio 画图
  15. 本科的控制工程到底学什么?
  16. 【必看文件含发帖规范】2020年黑马程序员社区总版规发布!
  17. 带手续费买卖股票的最大利益[找DP的状态定义到底缺什么?]
  18. <C++>类的对象内存空间分配一点就通,this指针一学就会
  19. 【毕业季·进击的技术er】青春不散场 恰同学少年
  20. 基于WiFi的室内定位

热门文章

  1. Windows的任务管理器怎么显示进程的图标
  2. 剧场版动画《巨虫列岛》1月上映决定!
  3. 【井字游戏】做一款回忆童年的游戏
  4. python中没有及|| 取而代之的是 and和or
  5. React 10分钟快速入门
  6. lcg_value() 函数
  7. 网易博客fengqing888搬家至CSDN啦
  8. IObit Malware Fighter 7 PRO 正版激活码
  9. 苏州大学9月计算机考试试题,2016年9月计算机一级考试试题含答案
  10. 互联网厂商介入智能手机业成趋势 前景不明朗