結果

問題 No.1479 Matrix Eraser
コンテスト
ユーザー eijirou
提出日時 2021-04-16 21:43:12
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 588 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 153 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 229,988 KB
最終ジャッジ日時 2026-03-24 08:32:43
合計ジャッジ時間 6,069 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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