defsearch_same_rowcol(data,m,n):
CharsetCache = {}
defpre_process():#预处理
kase = 0for i in range(m):
for j in range(n):
s = data[i][j]
if s in CharsetCache:data[i][j] = CharsetCache[s]
else:
CharsetCache[s] = kase
data[i][j] = kase
kase += 1deftest(r1,r2,col_start):for j in range(col_start+1,n):
if data[r1][j] == data[r2][j]:
print((r1+1,r2+1),(col_start+1,j+1))
returnTruereturnFalse
pre_process()
for j in range(n):
rec = {}
for i in range(m):#按列进行遍历if data[i][j] notin rec:
rec[data[i][j]] = i
else:#找到一样的元素
x = test(rec[data[i][j]],i,j)
if x : print(data);return
search_same_rowcol([['How to Compete in ACM ICPC','Peter','peter@aaa'],\
['How to win in ACM','Michael','michael'],['How to from','Michael','michael']],3,3)
from collections import namedtuple
building = namedtuple('building',['x','y','width','depth','height','index'])
building_cache = []
X_cache = set()
defprocess_input():global X_cache
kase = 0while(1):
x = input()
if x == '0':break
kase += 1
x = x.split(' ')
x = [int(each) for each in x]
b = building(x[0],x[1],x[2],x[3],x[4],kase)
X_cache.add(b.x)
X_cache.add(b.x+b.width)
building_cache.append(b)
X_cache = list(X_cache)
X_cache.sort()
building_cache.sort(key = lambda x:x.y)
building_cache.sort(key = lambda x:x.x)
defisvisible(b):
flag = Falsefor i in range(len(X_cache)-1):
left,right = X_cache[i],X_cache[i+1]
mid = (left+right)/2if covert(b,mid):
s = [1for each in building_cache if covert(each,mid) and each.y < b.y and each.height >= b.height]
if(s == []):flag = True#可以看见return flag
defcovert(b,mid):if b.x <= mid and b.x + b.width>= mid:
returnTrueelse:returnFalsedefProcess():
process_input()
for i,building in enumerate(building_cache):
if isvisible(building):
print(building.index,end = ' ')
Process()