結果

問題 No.2639 Longest Increasing Walk
ユーザー ニックネームニックネーム
提出日時 2024-02-19 21:34:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 972 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 53,712 KB
最終ジャッジ日時 2024-02-19 21:34:36
合計ジャッジ時間 11,285 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,112 KB
testcase_01 AC 26 ms
10,112 KB
testcase_02 AC 24 ms
10,112 KB
testcase_03 AC 24 ms
10,112 KB
testcase_04 AC 631 ms
45,568 KB
testcase_05 AC 904 ms
53,596 KB
testcase_06 AC 882 ms
52,776 KB
testcase_07 AC 938 ms
52,508 KB
testcase_08 AC 878 ms
53,508 KB
testcase_09 AC 972 ms
53,712 KB
testcase_10 AC 628 ms
29,840 KB
testcase_11 AC 573 ms
28,504 KB
testcase_12 AC 101 ms
12,672 KB
testcase_13 AC 675 ms
31,972 KB
testcase_14 AC 364 ms
21,632 KB
testcase_15 AC 24 ms
10,112 KB
testcase_16 AC 34 ms
10,368 KB
testcase_17 AC 352 ms
23,004 KB
testcase_18 AC 449 ms
23,756 KB
testcase_19 AC 127 ms
13,824 KB
testcase_20 AC 253 ms
18,432 KB
testcase_21 AC 526 ms
28,568 KB
testcase_22 AC 200 ms
16,128 KB
testcase_23 AC 27 ms
10,112 KB
testcase_24 AC 28 ms
10,112 KB
testcase_25 AC 29 ms
10,240 KB
testcase_26 AC 24 ms
10,112 KB
testcase_27 AC 30 ms
10,368 KB
testcase_28 AC 24 ms
10,112 KB
testcase_29 AC 24 ms
10,112 KB
testcase_30 AC 23 ms
10,112 KB
testcase_31 AC 24 ms
10,112 KB
testcase_32 AC 23 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
vij = []
for i in range(h):
    for j in range(w):
        vij.append((a[i][j],i,j))
dp = [[1]*w for _ in range(h)]
for v,pi,pj in sorted(vij):
    for di,dj in ((-1,0),(1,0),(0,-1),(0,1)):
        ni,nj = pi+di,pj+dj
        if h>ni>=0<=nj<w and a[ni][nj]>v:
            dp[ni][nj] = max(dp[ni][nj],dp[pi][pj]+1)
print(max(max(dp[i]) for i in range(h)))
0