結果

問題 No.1479 Matrix Eraser
ユーザー eijirou
提出日時 2021-04-16 21:43:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 248,184 KB
最終ジャッジ日時 2024-07-03 01:09:38
合計ジャッジ時間 9,624 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input = stdin.readline

def main():
    h, w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]

    rows = dict()
    columns = dict()
    for i in range(h):
        for j in range(w):
            if a[i][j] in rows:
                rows[a[i][j]].add(i)
                columns[a[i][j]].add(j)
            else:
                rows[a[i][j]] = {i}
                columns[a[i][j]] = {j}
    
    ans = 0
    for key in rows.keys():
        if key:
            ans += min(len(rows[key]), len(columns[key]))
    print(ans)

main()
0