Problem p02580 (python)

Fixed submission:
import sys
H, W, M = map(int, input().split())
h_list, w_list = [0]*H, [0]*W
check = set()
for _ in range(M):
    h, w = map(int, input().split())
    check.add((h-1, w-1))
    h_list[h-1] += 1
    w_list[w-1] += 1
h_max, w_max = max(h_list), max(w_list)
h_bom = [i for i in range(H) if h_list[i]==h_max]
w_bom = [i for i in range(W) if w_list[i]==w_max]
for h in h_bom:
    for w in w_bom:
        if not (h, w) in check:
            print(h_max+w_max)
            sys.exit()
print(h_max+w_max-1)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

H, W, M = map(int, input().split())
bom = np.zeros((H, W), dtype=int)
for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1, w-1] = 1
tate, yoko = bom.sum(axis=0), bom.sum(axis=1)
tate_max, yoko_max = tate.max(), yoko.max()
tate_list, yoko_list = [], []
for i in range(W):
    if tate[i] == tate_max: tate_list.append(i)
for i in range(H):
    if yoko[i] == yoko_max: yoko_list.append(i)
for h in yoko_list:
    for w in tate_list:
        if not bom[h][w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
H, W, M = map(int, input().split())
d = [[0]*H for _ in range(W)]
d = np.array(d)
for _ in range(M):
    h, w = map(int, input().split())
    d[h-1, w-1] = 1


tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []

for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)

for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if not d[h, w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
H, W, M = map(int, input().split())
d = np.zeros((H, W), dtype=np.int64)
for _ in range(M):
    h, w = map(int, input().split())
    #d[h-1, w-1] = 1

print(1)
exit()
tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []

for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)

for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if not d[h, w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
H, W, M = map(int, input().split())

d = np.zeros((H, W), dtype=np.int64)

for _ in range(M):
    h, w = map(int, input().split())
    d[h-1, w-1] = 1
print(1)
exit()
tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []

for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)

for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if not d[h, w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
H, W, M = map(int, input().split())
d = np.zeros((H, W), dtype=np.int64)

for _ in range(M):
    h, w = map(int, input().split())
    d[h-1, w-1] = 1
print(1)
tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []

for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)

for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if not d[h, w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import sys

H, W, M = map(int, input().split())
d = [[0]*W for _ in range(H)]
for _ in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    d[h][w] = 1
tate, yoko = [], []
for w in range(W):
    res = 0
    for h in range(H): res += d[h][w]
    tate.append(res)
for h in range(H):
    yoko.append(sum(d[h]))
    
tate_max = max(tate)
yoko_max = max(yoko)

ans_tate, ans_yoko = [], []
for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)
for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)        

for h in ans_yoko:
    for w in ans_tate:
        if d[h][w]!=1:
            print(tate_max+yoko_max)
            sys.exit()

print(tate_max+yoko_max-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
H, W, M = map(int, input().split())
d = np.zeros((H, W), dtype=int)
for _ in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    d[h, w] = 1
tate = np.sum(d, axis=0)
yoko = np.sum(d, axis=1)
tate_max = tate.max()
yoko_max = yoko.max()

ans_tate, ans_yoko = [], []
for i in range(W):
    if tate[i] == tate_max:
        ans_tate.append(i)
for i in range(H):
    if yoko[i] == yoko_max:
        ans_yoko.append(i)

for h in ans_yoko:
    for w in ans_tate:
        if d[h, w] != 1:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)