結果

問題 No.2639 Longest Increasing Walk
ユーザー 👑 rin204rin204
提出日時 2024-02-19 21:32:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 98,932 KB
最終ジャッジ日時 2024-02-19 21:32:56
合計ジャッジ時間 4,405 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 32 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 118 ms
97,524 KB
testcase_05 AC 132 ms
96,884 KB
testcase_06 AC 148 ms
98,676 KB
testcase_07 AC 143 ms
98,420 KB
testcase_08 AC 148 ms
98,932 KB
testcase_09 AC 165 ms
97,780 KB
testcase_10 AC 145 ms
88,180 KB
testcase_11 AC 155 ms
86,644 KB
testcase_12 AC 71 ms
75,220 KB
testcase_13 AC 156 ms
90,484 KB
testcase_14 AC 116 ms
82,816 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 AC 59 ms
69,164 KB
testcase_17 AC 99 ms
82,804 KB
testcase_18 AC 128 ms
84,608 KB
testcase_19 AC 76 ms
77,372 KB
testcase_20 AC 99 ms
80,640 KB
testcase_21 AC 134 ms
86,900 KB
testcase_22 AC 101 ms
79,244 KB
testcase_23 AC 46 ms
61,980 KB
testcase_24 AC 45 ms
61,976 KB
testcase_25 AC 51 ms
66,556 KB
testcase_26 AC 36 ms
53,460 KB
testcase_27 AC 56 ms
68,656 KB
testcase_28 AC 32 ms
53,460 KB
testcase_29 AC 33 ms
53,460 KB
testcase_30 AC 33 ms
53,460 KB
testcase_31 AC 33 ms
53,460 KB
testcase_32 AC 34 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
dp = [[0] * w for _ in range(h)]
lst = []
for i in range(h):
    for j in range(w):
        x = A[i][j] * h * w + i * w + j
        lst.append(x)

directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
lst.sort()
for tmp in lst:
    tmp %= h * w
    i = tmp // w
    j = tmp - i * w

    for di, dj in directions:
        ni, nj = i + di, j + dj
        if 0 <= ni < h and 0 <= nj < w and A[i][j] < A[ni][nj]:
            dp[ni][nj] = max(dp[ni][nj], dp[i][j] + 1)

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, dp[i][j])

print(ans + 1)
0