Source Code
#include<iostream>
#include<map>
using namespace std ;
int main()
{
   int n,m , days = 0 ;
   cin>>n>>m;
   map<int , int > hit ; 
   string bin[n];
   for(int i = 0 ; i< n ;i++)cin>>bin[i];
   
   for(int i=0 ; i<m ; i++)
   {
       int ones = 0 , theDay = -1  ;
       for(int j= 0 ; j<n ; j++)
       {
           if(bin[j][i] == '1' ) {ones ++; theDay = j;}
       }
       
       if(ones ==1 && theDay >=0 && hit[theDay] == 0) {days ++; hit[theDay]=1;}
   }
   cout<<days;
  
   
}
Copy
Obada Discovers His Hearing Issues Joud
GNU G++17
18 ms
2.9 MB
Accepted