結果

問題 No.1479 Matrix Eraser
ユーザー da_abda_ab
提出日時 2021-04-16 23:14:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 841 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 34,420 KB
最終ジャッジ日時 2023-09-16 02:37:52
合計ジャッジ時間 6,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
33,628 KB
testcase_01 AC 136 ms
29,184 KB
testcase_02 WA -
testcase_03 AC 136 ms
29,144 KB
testcase_04 WA -
testcase_05 AC 135 ms
29,252 KB
testcase_06 AC 137 ms
29,056 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
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 #

# 1479 Matrix Eraser

import numpy as np
from sys import stdin
readline=stdin.readline

h,w=map(int,readline().split())
A=np.array([list(map(int,readline().split()))])
for _ in range(1,h):
    A=np.append(A,np.array([list(map(int,readline().split()))]),axis=0)

cnt=0
while True:
    maxA=np.max(A)
    if maxA==0:
        break

    atMaxA=np.where(A==maxA)
    rowBinCnt=np.bincount(atMaxA[0])
    colBinCnt=np.bincount(atMaxA[1])
    rowBinCntMax=np.max(rowBinCnt)
    colBinCntMax=np.max(colBinCnt)
    if rowBinCntMax>=colBinCntMax:
        selectedRow=np.where(rowBinCnt==rowBinCntMax)[0][0]
        A[selectedRow]=np.where(A[selectedRow]==maxA,0,A[selectedRow])
    else:
        selectedCol=np.where(colBinCnt==colBinCntMax)[0][0]
        A[:,selectedCol]=np.where(A[:,selectedCol]==maxA,0,A[:,selectedCol])
    cnt+=1

print(cnt)


0