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

void solve()
{
    int n, m;
    int id[n+2] = { 0 };
    cin >> n >> m;
    char a[n+2][m+2];
    for (int r = 0; r < n; r++)
    {
        for (int c = 0; c < m; c++)
        {
            scanf(" %c", &a[r][c]);
        }
    }
    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)
        {
            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 lafi-Odeh
GNU G++17
657 ms
5.1 MB
Runtime Error