-
Notifications
You must be signed in to change notification settings - Fork 0
/
locate.py
58 lines (51 loc) · 1.52 KB
/
locate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# import numpy as np
test=int(input())
# n, m = map(int, input().split())
# x, y = input(), input()
map1=[]
map2=[]
# dem = [[0 for x in range(20001)] for y in range(20001)]
# dem = [[0]*2001 for i in range(2001)]
while (test>0):
n, m = [int(x) for x in input().split()]
dem = [[0]*(2*m+1) for i in range(2*n+1)]
for i in range (n):
entries = list(map(int, input().split())) #######
for j in range(m):
if(entries[j]==1): map1.append((i,j))
#######
# k=0
# for x in input().split():
# if(x==1):map1.append((i,k))
# k+=1
# if ((0*(1,2))==()): print ("ok") numpy reshape ......
# print(map1)
for i in range (n):
entries = list(map(int, input().split()))
for j in range(m):
if(entries[j]==1): map2.append((i,j))
for i in range(len(map1)):
for j in range(len(map2)):
dem[map1[i][0]-map2[j][0]+m][map1[i][1]-map2[j][1]+m] +=1
# print(count_nonzero(dem==1))
# print(np.max(dem))
print(max(max(x) for x in dem))
# print(max(max(dem))) sai
# map(max, dem)
# list(map(max, dem))
# print(max(map(max, dem)))
test-=1
# so=int(input())
# entries = list(map(int, input().split()))
# # for i in range (so):
# # arr.append(entries[i])
# entries.sort()
# # print(entries)
# # arr=[]1
# # for i in range (so):1
# # arr.append(entries[i])1
# # print(arr)1
# # arr[7][8]=2
# # print(max(max(x) for x in arr))
# for i in range (so):
# print(entries[i], end=" ")