結果

問題 No.2639 Longest Increasing Walk
ユーザー rikein12rikein12
提出日時 2024-02-19 21:37:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 403 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 121,720 KB
最終ジャッジ日時 2024-02-19 21:37:49
合計ジャッジ時間 6,578 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
55,612 KB
testcase_01 AC 33 ms
55,612 KB
testcase_02 AC 33 ms
55,612 KB
testcase_03 AC 34 ms
55,612 KB
testcase_04 AC 146 ms
118,648 KB
testcase_05 AC 177 ms
121,464 KB
testcase_06 AC 186 ms
121,592 KB
testcase_07 AC 265 ms
121,720 KB
testcase_08 AC 207 ms
121,592 KB
testcase_09 AC 308 ms
121,592 KB
testcase_10 AC 384 ms
100,888 KB
testcase_11 AC 371 ms
97,368 KB
testcase_12 AC 150 ms
80,304 KB
testcase_13 AC 403 ms
107,256 KB
testcase_14 AC 287 ms
93,060 KB
testcase_15 AC 34 ms
55,608 KB
testcase_16 AC 56 ms
70,700 KB
testcase_17 AC 250 ms
93,176 KB
testcase_18 AC 320 ms
95,492 KB
testcase_19 AC 175 ms
81,964 KB
testcase_20 AC 253 ms
88,324 KB
testcase_21 AC 367 ms
97,552 KB
testcase_22 AC 225 ms
85,088 KB
testcase_23 AC 38 ms
55,604 KB
testcase_24 AC 40 ms
55,604 KB
testcase_25 AC 48 ms
66,552 KB
testcase_26 AC 34 ms
55,608 KB
testcase_27 AC 50 ms
66,540 KB
testcase_28 AC 34 ms
55,612 KB
testcase_29 AC 33 ms
55,612 KB
testcase_30 AC 33 ms
55,612 KB
testcase_31 AC 33 ms
55,612 KB
testcase_32 AC 34 ms
55,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(H):
    for j in range(W):
        B.append((A[i][j],i,j))

B.sort(key=lambda x:x[0])

from collections import defaultdict

DP = [[0]*W for i in range(H)]
ans = 0
for a, i, j in B:
    dp = 0
    if i > 0 and A[i-1][j] < a:
        dp = max(DP[i-1][j], dp)
    if j > 0 and A[i][j-1] < a:
        dp = max(DP[i][j-1], dp)
    if i < H-1 and A[i+1][j] < a:
        dp = max(DP[i+1][j], dp)
    if j < W-1 and A[i][j+1] < a:
        dp = max(DP[i][j+1], dp)
    DP[i][j] = dp + 1
    ans = max(dp+1,ans)
print(ans)
0