逆序对。
CODE:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define DOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define bug puts("Fuck");
#define LL long long
#define pb push_back
#define mp make_pair
#define nMax 101000
#define eps 1e-8
#define inf 0x7fffffff
int a[nMax],b[nMax];
int ans[22],n,k;
void bsort(int *a,int l,int r,int k){
if(l==r) return ;
int mid=(l+r)>>1;
bsort(a,l,mid,k);
bsort(a,mid+1,r,k);
int i=l,j=mid+1,s=0;
while(i<=mid && j<=r){
if(a[i] < a[j]) b[s++]=a[i++];
else ans[k]+=(mid-i+1),b[s++]=a[j++];
}
while(i<=mid) b[s++]=a[i++];
while(j<=r) b[s++]=a[j++];
for(i=0;i<s;i++) a[l+i]=b[i];
return ;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
while(~scanf("%d%d",&n,&k)){
int s=1;
for(int i=1;i<=k;i++) {
FOR(j,0,n-1) scanf("%d",&a[j]);
ans[i]=0;
bsort(a,0,n-1,i);
if(ans[i] > ans[s]) s=i;
}
printf("%d\n",s);
}
return 0;
}