P5831 [USACO19DEC]Cow Gymnastics奶牛体操
- 申请一个二维数组记录配对关系,值为k的就递增tot
#include<iostream>
using namespace std;
int a[11][21],tot,b[21][21];
int main()
{int k,n;cin >> k >> n;for(int i = 1;i <= k;i++)for(int j = 1;j <= n;j++)cin >> a[i][j];for(int i = 1;i <= k;i++)for(int j = 1;j < n;j++)for(int q = j+1;q <= n;q++){b[a[i][j]][a[i][q]]++;}for(int i = 1;i <= n;i++)for(int j = 1;j <= n;j++)if(b[i][j] == k)tot++;cout << tot;
}
大佬
看似两层循环,实则再加上cmp函数有三层
#include<bits/stdc++.h>
using namespace std;int n,k;
int tmp;
int cnt;
int a[100][100];
bool cmp(int x,int y){for(int i=1;i<=k;i++){if(a[i][x]>a[i][y]){return false;}}return true;
}
int main()
{cin>>k>>n;for(int i=1;i<=k;i++){for(int j=1;j<=n;j++){cin>>tmp;a[i][tmp]=j;}}for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){if(i==j){continue;}if(cmp(i,j)){cnt++;}}}cout<<cnt;return 0;
}
P5831 [USACO19DEC]Cow Gymnastics奶牛体操相关推荐
- P5831 [USACO19DEC]Cow Gymnastics B
P5831 [USACO19DEC]Cow Gymnastics B - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) #include<bits/stdc++.h>usi ...
- A.Cow Gymnastics 奶牛体操
GDUT 2020寒假训练 排位赛一 A 原题链接 A. Cow Gymnastics 题目 描述 In order to improve their physical fitness, the co ...
- 洛谷P5831 Python [USACO19DEC]Cow Gymnastics B
题目描述 为了提高健康水平,奶牛们开始进行体操训练了!Farmer John 选定了他最喜爱的奶牛 Bessie 来执教其他 NN 头奶牛,同时评估她们学习不同的体操技术的进度. KK 次训练课的每一 ...
- 洛谷刷题C语言:陶瓷项链、Cow Gymnastics B、Where Am I? B、Hello, 2020!、SIR 模型
记录洛谷刷题C语言 一.[NOI2000] 瓷片项链 题目描述 原始部落用一种稀有的泥土烧制直径相同的圆瓷片并串成项链,串的时候沿瓷片的直径方向顺次连接,瓷片之间没有空隙也不重叠,一条项链至少由一个瓷 ...
- 排位赛1-A Cow Gymnastics
排位赛1-A Cow Gymnastics 题目 In order to improve their physical fitness, the cows have taken up gymnasti ...
- 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 ...
- BZOJ 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛【Floyd】
1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 Time Limit: 5 Sec Memory Limit: 64 MB Description FJ的N(1 <= ...
- bzoj 1654: [Usaco2006 Jan]The Cow Prom 奶牛舞会 -- Tarjan
1654: [Usaco2006 Jan]The Cow Prom 奶牛舞会 Time Limit: 5 Sec Memory Limit: 64 MB Description The N (2 & ...
- bzoj 3377: [Usaco2004 Open]The Cow Lineup 奶牛序列
3377: [Usaco2004 Open]The Cow Lineup 奶牛序列 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 49 Solve ...
最新文章
- javascript图片浏览器的核心——图片预加载
- Maven的Spring Security
- 计算机二级web题目(1)--web基础
- php 不返回 数据,php – file_get_contents没有返回任何数据
- 树莓派蜂鸣器python代码_[原创]初玩树莓派B 5控制蜂鸣器演奏乐曲
- 评价——模糊综合评价
- 【JS】Unicode编码
- Spring boot yml的格式
- 平衡二叉树的原理及实现
- 上海航芯 | 从STM32F103到ACM32F403的U盘程序移植工程
- 机器学习基础补习04---凸优化
- 游戏引擎架构-学习笔记
- 转载 CATransform3D 矩阵 m11–m44每个的含义
- 2019最应该投资什么?是你明年的北大核心
- 手把手带你入坑树莓派(3B+)之第二篇,使用Putty与电脑VNC远程控制树莓派
- java 算出下一个工作日_Java 计算一段时间段内除去周六日、节假日的工作日数———超详细(全)...
- vmospro启动黑屏_在Mac上从睡眠唤醒中修复黑屏 | MOS86
- 点亮AliOS Things IOT(STM32L496VGTx)开发板上的的ST7789 OLED全彩屏
- Linux不是Windows(转)
- mplayer-php,使用MPlayer开发万能播放器-原理篇