結果
問題 | No.1479 Matrix Eraser |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-04-16 21:13:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,265 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 87,072 KB |
実行使用メモリ | 121,484 KB |
最終ジャッジ日時 | 2023-09-15 23:03:26 |
合計ジャッジ時間 | 14,490 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
85,296 KB |
testcase_01 | AC | 108 ms
80,948 KB |
testcase_02 | WA | - |
testcase_03 | AC | 108 ms
80,848 KB |
testcase_04 | WA | - |
testcase_05 | AC | 111 ms
80,772 KB |
testcase_06 | AC | 108 ms
80,960 KB |
testcase_07 | AC | 217 ms
101,744 KB |
testcase_08 | AC | 251 ms
103,444 KB |
testcase_09 | AC | 290 ms
109,288 KB |
testcase_10 | AC | 401 ms
116,076 KB |
testcase_11 | AC | 314 ms
110,824 KB |
testcase_12 | AC | 218 ms
102,140 KB |
testcase_13 | AC | 248 ms
103,484 KB |
testcase_14 | AC | 224 ms
102,588 KB |
testcase_15 | AC | 161 ms
99,424 KB |
testcase_16 | AC | 233 ms
103,080 KB |
testcase_17 | AC | 498 ms
121,248 KB |
testcase_18 | AC | 512 ms
120,768 KB |
testcase_19 | AC | 488 ms
120,700 KB |
testcase_20 | AC | 503 ms
120,828 KB |
testcase_21 | AC | 512 ms
120,732 KB |
testcase_22 | AC | 485 ms
121,228 KB |
testcase_23 | AC | 506 ms
121,484 KB |
testcase_24 | AC | 481 ms
120,800 KB |
testcase_25 | AC | 504 ms
121,168 KB |
testcase_26 | AC | 488 ms
120,712 KB |
testcase_27 | TLE | - |
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 | -- | - |
ソースコード
from collections import defaultdict h,w = map(int,input().split()) A = [list(map(int,input().split())) for i in range(h)] xy = [[] for i in range(5*10**5+5)] for i in range(h): for j in range(w): xy[A[i][j]].append((i,j)) ans = 0 for i in range(5*10**5,0,-1): if xy[i] == []: continue dich = defaultdict(int) dicw = defaultdict(int) for x,y in xy[i]: dich[x] += 1 dicw[y] += 1 dels = set() while True: mh = 0 ih = 0 mw = 0 iw = 0 for k,v in dich.items(): if v > mh: mh = v ih = k for k,v in dicw.items(): if v > mw: mw = v iw = k if mh == mw == 0: break ans += 1 if mh >= mw: dich[ih] = 0 for x,y in xy[i]: if (x,y) in dels: continue if x == ih: dicw[y] -= 1 dels.add((x,y)) else: dicw[iw] = 0 for x,y in xy[i]: if (x,y) in dels: continue if y == iw: dich[x] -= 1 dels.add((x,y)) print(ans)