Source Code
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long int
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void solve() {
	int n, m; cin >> n >> m;
	int p = 0, c = 0, t = 0;
	vector <string> a(n);
	map <int, bool> f;
	forn(i, n) {
		cin >> a[i];
	}
	forn(i, m) {
		p = 0; t = 0;
		forn(j, n) {
			
			if (a[j][i] == '1' && p==0) {
				t = j;
				p++;
			}
			else if (a[j][i] == '1') {
				p++;
			}
		}
	
		if(p==1) f[t+1] = true;
	}
	for (int i =1; i <= n; i++) {
		if (f[i]) c++;
	}
	cout << c;
}

int main(void) {
	FastIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Copy
Obada Discovers His Hearing Issues misterRoshi22
GNU G++17
5 ms
2.1 MB
Accepted