| 3 | #include<stdio.h> |
| 4 | |
| 5 | int main(){ |
| 6 | |
| 7 | int n,classes,attended=0,max=0,max_count=0,k; |
| 8 | scanf("%d%d",&n,&classes); //n stores the number of persons and classes stores the maximum subjects a person can know |
| 9 | |
| 10 | char attendance[n][classes]; //2D array to store the classes attended |
| 11 | |
| 12 | for(int i=0;i<n;i++) |
| 13 | scanf("%s",attendance[i]); //take inputs into the array |
| 14 | |
| 15 | for(int i=0;i<n-1;i++){ |
| 16 | k=i+1; //to check between this ith and kth one |
| 17 | while(k<n){ |
| 18 | attended=0; |
| 19 | for(int j=0;j<classes;j++){ |
| 20 | if(attendance[i][j]=='1'||attendance[k][j]=='1') //we calculate here every permutation possible for two person team and check the maximum subjects they both know |
| 21 | attended++; |
| 22 | } |
| 23 | if(max<attended){ |
| 24 | max=attended; //updating the maximum value |
| 25 | max_count=1; //updating the max count as a new value means only that pair yields the maximum value and rest we need to calculate later |
| 26 | } |
| 27 | else if(max==attended) |
| 28 | max_count++; //max==attended means maximum value and it's pair already exists, so updating max_count |
| 29 | k++; //updating k to compute next pair |
| 30 | } |
| 31 | } |
| 32 | printf("%d\n%d",max,max_count); ///printing the desired output in it's desired format |
| 33 | return 0; |
| 34 | } |
nothing calls this directly
no outgoing calls
no test coverage detected