Source Code
#include <bits/stdc++.h>
using namespace std;

void solve()
{
int n, m;
int id[n]={0};
cin>>n>>m;
char a[n][m];
for(int r=0;r<n;r++)
{
    for(int c=0;c<m;c++)
    {
        scanf(" %c",&a[r][c]);
    }
}
int counter=0;
int index;
for(int c=0;c<m;c++)
{
    int cnt=0;
    for(int r=0;r<n;r++)
    {
        if(a[r][c]=='1')
        {
            cnt++;
            index=r;
        }

    }
    if(cnt==1)
    {
        counter++;
        id[index]=1;
    }
}
int ct=0;
for(int i=0;i<n;i++)
{
    if(id[i]==1) ct++;
}
printf("%d",ct);
}

int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
	return 0;
}
Copy
Obada Discovers His Hearing Issues TATAKAE
GNU G++17
624 ms
4.9 MB
Runtime Error