EMPFLAT - Editorial

PROBLEM LINK:

Practice
Contest

Author: Riddhish Lichade
Tester: Prathamesh Sogale
Editorialist: Ram Agrawal

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Arrays

PROBLEM:

We are given with a 2-D array containing only 1s and 0s. The array represents the state of windows in flats of a building.1s represents the open window and 0 represents a closed window. Each flat has 2 windows. We have to find the number of empty flats. A flat is empty if both its windows are closed.

EXPLANATION:

Traverse the given 2-D array. For each floor check 2 windows at a time. If both the elements are 0, then increment the counter by 1. Print the count at last

SOLUTION:

Setter's Solution
from sys import stdin
for _ in range(int(stdin.readline())):
    n, f = map(int, stdin.readline().strip().split())
    ans=0
    for i in range(n):
        l=list(map(int, stdin.readline().strip().split()))
        i=0
        while(i<f*2):
            if(l[i]==0 and l[i+1]==0):
                ans+=1
            i+=2
    print(ans)