結果

問題 No.2639 Longest Increasing Walk
ユーザー shobonvipshobonvip
提出日時 2024-02-19 18:24:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,675 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 334,464 KB
最終ジャッジ日時 2024-02-19 20:50:34
合計ジャッジ時間 6,072 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 140 ms
81,776 KB
testcase_05 AC 162 ms
86,256 KB
testcase_06 AC 172 ms
86,128 KB
testcase_07 AC 226 ms
90,992 KB
testcase_08 AC 178 ms
87,024 KB
testcase_09 AC 1,675 ms
334,464 KB
testcase_10 AC 156 ms
79,984 KB
testcase_11 AC 147 ms
79,344 KB
testcase_12 AC 93 ms
76,860 KB
testcase_13 AC 156 ms
80,496 KB
testcase_14 AC 131 ms
78,588 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 68 ms
73,712 KB
testcase_17 AC 132 ms
78,704 KB
testcase_18 AC 145 ms
79,100 KB
testcase_19 AC 97 ms
77,160 KB
testcase_20 AC 117 ms
78,332 KB
testcase_21 AC 148 ms
79,728 KB
testcase_22 AC 106 ms
77,724 KB
testcase_23 AC 49 ms
63,808 KB
testcase_24 AC 47 ms
61,712 KB
testcase_25 AC 60 ms
71,260 KB
testcase_26 AC 35 ms
53,460 KB
testcase_27 AC 63 ms
72,804 KB
testcase_28 AC 35 ms
53,460 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 35 ms
53,460 KB
testcase_31 AC 35 ms
53,460 KB
testcase_32 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(998244)

h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
dp = [[0]*w for i in range(h)]
seen = [[0]*w for i in range(h)]

def dfs(i, j):
	if seen[i][j]:
		return dp[i][j]
	
	ret = 1
	for x, y in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:
		if 0 <= x < h and 0 <= y < w and a[x][y] > a[i][j]:
			ret = max(ret, dfs(x, y) + 1)
	dp[i][j] = ret
	seen[i][j] = 1
	return ret

ans = 0
for i in range(h-1,-1,-1):
	for j in range(w-1,-1,-1):
		ans = max(ans, dfs(i, j))

print(ans)
0