#include<bits/stdc++.h> using namespace std; int main( ) { //int t; //cin>>t; //while(t--) //{ int c,v,arr[109][109],d[109]={0}; int x=0; bool check=false; int a=0,b=0; int aa=0,bb=0; cin>>c>>v; for(int i=0 ; i<v; i++) { for(int j=0 ; j<c ; j++) { cin>>arr[i][j]; } } for(int j=0 ; j<v ; j++) { d[arr[j][0]]++; } for(int j=1 ; j<=c ; j++) { x=max(d[j],x); if(d[j]==x && check==false) {a=j; aa=d[j]; check=true;} else if(d[j]==x && check==true) {b=j; bb=d[j]; check=false;} } //cout<<aa<<" "<<bb<< " " <<a <<" "<<b<<endl; if(aa>bb && aa>floor(.5*v)) {cout<<a<<" 1"<<endl; return 0;} else if(bb>aa && bb>floor(.5*v)) {cout<<b<<" 1"<<endl; return 0;} else { int r=1; while(true) { aa=0; bb=0; for(int j=0 ; j<v ; j++) { if(arr[j][r]==a) aa++; else if(arr[j][r]==b) bb++; } //cout<<aa<<" "<<bb<< " " <<a <<" "<<b<<endl; if(aa>bb) {cout<<a<<" 2"<<endl; return 0;} else if(bb>aa) {cout<<b<<" 2"<<endl; return 0;} r++; } } //} return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)