Source Code
#include <stdio.h>

int main(){
    long n,m;
    scanf("%ld%ld",&n,&m);
    char a[n][m];
    for(int i = 0; i < n ; i++){
        scanf("%s",a[i]);
    }
    long b[n];
    for(int i = 0; i < n; i++){
        b[i] = 0;
    }
    int flag = 0;
    for(int j = 0; j < n; j++){
    for(int i = 0; i < m; i++){
        flag = 0;
        if(a[j][i] == '1'){
            for(int k = 0; k < n; k++){
                if(a[k][i] == '1' && k!= j){
                    flag = 3;
                    break;
                }
            }
            if(flag == 0 && b[j] == 0) b[j] = 1;
        }
    }
    }
    long sum = 0;
    for(int i = 0; i < n; i++){
        sum += b[i];
    }
    printf("%ld",sum);
    
}
Copy
Obada Discovers His Hearing Issues Ayoooy
GNU G++17
7 ms
1.8 MB
Accepted