結果

問題 No.2639 Longest Increasing Walk
ユーザー shobonvipshobonvip
提出日時 2024-02-19 18:23:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,500 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 348,548 KB
最終ジャッジ日時 2024-02-19 20:50:31
合計ジャッジ時間 6,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 33 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 33 ms
53,460 KB
testcase_04 AC 124 ms
81,904 KB
testcase_05 AC 145 ms
83,824 KB
testcase_06 AC 172 ms
88,304 KB
testcase_07 AC 1,500 ms
348,548 KB
testcase_08 AC 167 ms
84,464 KB
testcase_09 AC 221 ms
87,536 KB
testcase_10 AC 218 ms
82,160 KB
testcase_11 AC 189 ms
80,624 KB
testcase_12 AC 93 ms
76,792 KB
testcase_13 AC 198 ms
81,648 KB
testcase_14 AC 171 ms
80,380 KB
testcase_15 AC 33 ms
53,460 KB
testcase_16 AC 73 ms
76,328 KB
testcase_17 AC 168 ms
79,728 KB
testcase_18 AC 176 ms
80,764 KB
testcase_19 AC 116 ms
77,924 KB
testcase_20 AC 161 ms
79,484 KB
testcase_21 AC 198 ms
81,520 KB
testcase_22 AC 145 ms
78,488 KB
testcase_23 AC 43 ms
63,804 KB
testcase_24 AC 44 ms
63,920 KB
testcase_25 AC 49 ms
66,552 KB
testcase_26 AC 35 ms
53,460 KB
testcase_27 AC 57 ms
70,724 KB
testcase_28 AC 32 ms
53,460 KB
testcase_29 AC 32 ms
53,460 KB
testcase_30 AC 33 ms
53,460 KB
testcase_31 AC 31 ms
53,460 KB
testcase_32 AC 30 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):
	for j in range(w):
		ans = max(ans, dfs(i, j))

print(ans)
0