結果

問題 No.2639 Longest Increasing Walk
ユーザー こめだわらこめだわら
提出日時 2024-02-19 21:45:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 96,292 KB
最終ジャッジ日時 2024-02-19 21:45:52
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 124 ms
89,720 KB
testcase_05 AC 181 ms
95,680 KB
testcase_06 AC 164 ms
95,760 KB
testcase_07 AC 206 ms
94,984 KB
testcase_08 AC 168 ms
95,640 KB
testcase_09 AC 223 ms
96,292 KB
testcase_10 AC 257 ms
88,504 KB
testcase_11 AC 230 ms
81,400 KB
testcase_12 AC 77 ms
74,492 KB
testcase_13 AC 251 ms
83,592 KB
testcase_14 AC 159 ms
78,980 KB
testcase_15 AC 32 ms
53,460 KB
testcase_16 AC 52 ms
68,788 KB
testcase_17 AC 119 ms
79,224 KB
testcase_18 AC 181 ms
80,388 KB
testcase_19 AC 98 ms
77,052 KB
testcase_20 AC 142 ms
78,784 KB
testcase_21 AC 210 ms
81,144 KB
testcase_22 AC 110 ms
77,792 KB
testcase_23 AC 44 ms
61,992 KB
testcase_24 AC 43 ms
61,992 KB
testcase_25 AC 50 ms
66,700 KB
testcase_26 AC 33 ms
53,460 KB
testcase_27 AC 50 ms
66,688 KB
testcase_28 AC 31 ms
53,460 KB
testcase_29 AC 31 ms
53,460 KB
testcase_30 AC 33 ms
53,460 KB
testcase_31 AC 34 ms
53,460 KB
testcase_32 AC 31 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

B=list(range(H*W))
B.sort(key=lambda x:A[x//W][x%W])
D=[[1]*W for _ in range(H)]

dd=[(0,1),(1,0),(-1,0),(0,-1)]

for p in B:
    i,j=divmod(p,W)
    for di,dj in dd:
        ni=i+di
        nj=j+dj
        if 0<=ni<H and 0<=nj<W:
            if A[ni][nj]>A[i][j]:
                D[ni][nj]=max(D[ni][nj],D[i][j]+1)

print(max(max(D[i]) for i in range(H)))
0