結果

問題 No.1479 Matrix Eraser
ユーザー 小野寺健小野寺健
提出日時 2021-04-27 18:35:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 790 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 37,712 KB
最終ジャッジ日時 2023-09-20 19:05:41
合計ジャッジ時間 7,654 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,660 KB
testcase_01 AC 16 ms
8,136 KB
testcase_02 AC 18 ms
8,164 KB
testcase_03 AC 18 ms
8,288 KB
testcase_04 AC 18 ms
8,348 KB
testcase_05 AC 17 ms
8,156 KB
testcase_06 AC 18 ms
8,260 KB
testcase_07 AC 162 ms
11,164 KB
testcase_08 AC 370 ms
13,612 KB
testcase_09 AC 1,338 ms
20,440 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())

S = []

for i in range(H):
    for j, a in enumerate(list(map(int, input().split()))):
        if a > 0:
            S.append((a, i, j))
            
S.sort(reverse=True)

cnt = 0
while len(S) > 0:
    A = []
    A.append(S.pop(0))
    while len(S) > 0 and A[0][0] == S[0][0]:
        A.append(S.pop(0))
    Q = [(A, 1)]
    while len(Q) > 0:
        B, n = Q.pop(0)
        I = []
        for b in B[1:]:
            if B[0][1] != b[1]:
                I.append(b)
        if len(I) == 0:
            cnt += n
            break
        Q.append((I, n+1))
        J = []
        for b in B[1:]:
            if B[0][2] != b[2]:
                J.append(b)
        if len(J) == 0:
            cnt += n
            break
        Q.append((J, n+1))

print(cnt)
0