Source Code

#include <iostream>
using namespace std;
int a1[10001];

int main()
{
    string a[10001];
    int n, m;
    cin >> n >> m;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        int sum = 0;
        int ansindex;
        for (int j = 0; j < n; j++)
        {
            if (a[j][i] == '1') {
                ansindex = j;
            }
            sum += a[j][i] - 48;
            // cout << sum << endl;
        }
        if (sum == 1)
        {
            a1[ansindex]++;
            if (a1[ansindex] == 1)
            {
                count++;
            }
        }


    }
    cout << count;
}
Copy
Obada Discovers His Hearing Issues microwave6
GNU G++17
21 ms
3.1 MB
Accepted