結果

問題 No.1479 Matrix Eraser
ユーザー AEnAEn
提出日時 2023-06-02 00:29:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 81,096 KB
最終ジャッジ日時 2023-08-28 02:13:49
合計ジャッジ時間 10,179 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,700 KB
testcase_01 AC 86 ms
71,520 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 86 ms
71,340 KB
testcase_07 AC 131 ms
78,788 KB
testcase_08 AC 134 ms
78,912 KB
testcase_09 AC 142 ms
79,136 KB
testcase_10 AC 181 ms
80,560 KB
testcase_11 AC 155 ms
79,528 KB
testcase_12 AC 125 ms
78,672 KB
testcase_13 AC 126 ms
78,700 KB
testcase_14 AC 130 ms
78,556 KB
testcase_15 AC 105 ms
77,644 KB
testcase_16 AC 130 ms
78,992 KB
testcase_17 AC 193 ms
80,684 KB
testcase_18 AC 194 ms
80,712 KB
testcase_19 AC 195 ms
80,964 KB
testcase_20 AC 185 ms
80,876 KB
testcase_21 AC 184 ms
80,708 KB
testcase_22 AC 193 ms
80,800 KB
testcase_23 AC 195 ms
81,096 KB
testcase_24 AC 193 ms
80,768 KB
testcase_25 AC 195 ms
80,848 KB
testcase_26 AC 190 ms
80,656 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 135 ms
80,260 KB
testcase_33 AC 134 ms
80,408 KB
testcase_34 AC 135 ms
80,316 KB
testcase_35 AC 144 ms
80,212 KB
testcase_36 AC 144 ms
80,340 KB
testcase_37 AC 131 ms
79,956 KB
testcase_38 AC 185 ms
80,752 KB
testcase_39 AC 185 ms
80,576 KB
testcase_40 AC 87 ms
71,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

H,W = map(int, input().split())
A = [list(map(int,input().split())) for _ in range(H)]

res = 0
for i in range(H):
    d = defaultdict(list)
    for j in range(W):
        if A[i][j]!=0:
            d[A[i][j]].append(j)
    for key in d.keys():
        if len(d[key])>1:
            res += 1
            for x in d[key]:
                A[i][x] = 0

for i in range(W):
    d = defaultdict(list)
    for j in range(H):
        if A[j][i]!=0:
            d[A[j][i]].append(j)
    for key in d.keys():
        if len(d[key])>1:
            res += 1
            for y in d[key]:
                A[y][i] = 0

for i in range(H):
    res += W-A[i].count(0)
print(res)
0