Created
May 12, 2014 15:10
-
-
Save lethe2211/68e2ba47a2ae4bd8356a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def func(): | |
hw = map(int, raw_input().split()) | |
h = hw[0] | |
w = hw[1] | |
display = [] | |
for i in range(h): | |
row = raw_input() | |
display.append(row) | |
n = int(raw_input()) | |
for i in range(n): | |
widget = raw_input().split() | |
s = int(widget[0]) | |
t = int(widget[1]) | |
count = 0 | |
for j, row in enumerate(display): | |
for i, elem in enumerate(row): | |
flag = False | |
for dy in range(s): | |
for dx in range(t): | |
if j+dy >= h or i+dx >= w or display[j+dy][i+dx] == '1': | |
flag = True | |
break | |
if flag == True: | |
break | |
else: | |
count += 1 | |
print count | |
return None | |
if __name__ == '__main__': | |
func() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment