Problem p02580 (python)

Fixed submission:
H,W,M = map(int,input().split())
tate,yoko = [0]*W,[0]*H
ans = 0
memo = set([])
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  memo.add((h,w))
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if (i,j) not in memo:
      print(t+y)
      exit()

print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
memo = set([])
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
  memo.add((h,w))
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if (i,j) not in memo:
      print(t+y)
      exit()

print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
memo = []
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
  memo.append([h,w])
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if [i,j] in memo:
      pass
    else:
      print(t+y)
      exit()
print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if l[i][j] == 0:
      print(t+y)
      exit()
print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
memo = []
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
  memo.append([h,w])
tateArr,yokoArr = [],[]

t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i,j in memo:
  if j not in tateArr and i not in yokoArr:
    print(t+y)
    exit()
print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if l[i][j] == 0:
      print(t+y)
      exit()
print(t+y-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
tateArr,yokoArr = [0,0],[0,0]
ans = 0
for i in range(W):
  if tate[i] > tateArr[0]:
    tateArr = [tate[i],i]
for i in range(H):
  if yoko[i] > yokoArr[0]:
    yokoArr = [yoko[i],i]

print(tateArr[0]+yokoArr[0]-l[yokoArr[1]][tateArr[1]])