結果

問題 No.1479 Matrix Eraser
ユーザー eijiroueijirou
提出日時 2021-04-16 21:43:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 246,952 KB
最終ジャッジ日時 2023-09-16 00:00:12
合計ジャッジ時間 11,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,376 KB
testcase_01 AC 70 ms
71,060 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 110 ms
89,244 KB
testcase_08 AC 151 ms
116,340 KB
testcase_09 AC 210 ms
130,740 KB
testcase_10 AC 385 ms
194,196 KB
testcase_11 AC 261 ms
152,876 KB
testcase_12 AC 112 ms
90,896 KB
testcase_13 AC 149 ms
116,124 KB
testcase_14 AC 111 ms
90,684 KB
testcase_15 AC 83 ms
76,952 KB
testcase_16 AC 115 ms
91,920 KB
testcase_17 AC 438 ms
212,440 KB
testcase_18 AC 441 ms
212,312 KB
testcase_19 AC 454 ms
212,400 KB
testcase_20 AC 449 ms
212,452 KB
testcase_21 AC 447 ms
212,548 KB
testcase_22 AC 448 ms
212,380 KB
testcase_23 AC 460 ms
212,536 KB
testcase_24 AC 452 ms
212,388 KB
testcase_25 AC 461 ms
212,388 KB
testcase_26 AC 460 ms
212,584 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 111 ms
78,752 KB
testcase_33 AC 111 ms
78,952 KB
testcase_34 AC 111 ms
79,016 KB
testcase_35 AC 111 ms
78,852 KB
testcase_36 AC 110 ms
78,856 KB
testcase_37 AC 112 ms
78,924 KB
testcase_38 AC 156 ms
90,188 KB
testcase_39 AC 396 ms
246,952 KB
testcase_40 AC 73 ms
71,136 KB
権限があれば一括ダウンロードができます

ソースコード

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