You are given a list of N people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can know. And also find out how many teams can know that maximum number of topics.
Note Suppose a, b, and c are three different people, then (a,b) and (b,c) are counted as two different teams.
Input Format
The first line contains two integers, N and M , separated by a single space, where N represents the number of people, and M represents the number of topics. N lines follow.
Each line contains a binary string of lengthM . If the i th line's j th character is 1 , then the i thperson knows the j th topic; otherwise, he doesn't know the topic.
Each line contains a binary string of length
Constraints
2≤N≤500
1≤M≤500
Output Format
On the first line, print the maximum number of topics a 2-person team can know.
On the second line, print the number of 2-person teams that can know the maximum number of topics.
On the second line, print the number of 2-person teams that can know the maximum number of topics.
Sample Input
4 5
10101
11100
11010
00101
Sample Output
5
2
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int arr[500][500],n,m,i,j,k,problem=0,team=0;
char val[600][600];
cin>>n>>m;
for(i=0;i<n;i++){
cin>>val[i];
}
int tproblem = 0,tteam = 0,flag =0;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++)
{
flag = 0;
tproblem = 0;
for(k=0;k<m;k++){
int x,y;
x = val[i][k]-48;
y = val[j][k]-48;
//cout<<x<<"x";
if(x|y){
tproblem ++;
}
}
if(tproblem == problem){
tteam++;
}
if(tproblem > problem){
problem = tproblem;
tteam= 1;
}
}
}
cout<<problem<<endl<<tteam<<endl;
return 0;
}