P5831 [USACO19DEC]Cow Gymnastics B
作者:互联网
P5831 [USACO19DEC]Cow Gymnastics B - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
#include<bits/stdc++.h>
using namespace std;
int a[30][30], t[30];
int main()
{
int k, n;
scanf("%d%d",&k,&n);
while(k--) //k天 , n头奶牛
{
for(int i = 1; i <= n; i++) // 读入一天的数据
scanf("%d",&t[i]);
for(int i = 1; i < n; i++)
for(int j = i + 1; j <= n; j++)
a[t[j]][t[i]] = 1;
}
int cnt = 0;
for(int i = 1; i <= n;i++)
for(int j = 1; j <=n; j++)
if(a[i][j]==1) cnt++;
printf("%d",n*n - n - cnt);//总数-对角线-逆序的数
return 0;
}
标签:USACO19DEC,Cow,int,30,Gymnastics,P5831 来源: https://blog.csdn.net/EDGNB6666/article/details/122727105