• Source
    1. #include <iostream>
    2. #include <string>
    3. using namespace std;
    4. const int N=505;
    5. string a[N];
    6. int main()
    7. {
    8. int n,m;
    9. cin>>n>>m;
    10. for(int i=0;i<n;++i)
    11. cin>>a[i];
    12. int maxSubject=0,num=0;
    13. for(int i=0;i<n;++i)
    14. for(int j=i+1;j<n;++j)
    15. {
    16. int temp=0;
    17. for(int k=0;k<m;++k)
    18. if(a[i][k]=='1' || a[j][k]=='1')
    19. ++temp;
    20. if(temp>maxSubject)
    21. {
    22. maxSubject=temp;
    23. num=1;
    24. }
    25. else
    26. if(temp==maxSubject)
    27. ++num;
    28. }
    29.  
    30. cout<<maxSubject<<endl<<num<<endl;
    31. return 0;
    32. }