結果

問題 No.2639 Longest Increasing Walk
ユーザー shobonvipshobonvip
提出日時 2024-02-19 18:24:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 949 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 165,504 KB
最終ジャッジ日時 2024-02-19 20:50:34
合計ジャッジ時間 7,779 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,112 KB
testcase_01 AC 26 ms
10,112 KB
testcase_02 AC 26 ms
10,112 KB
testcase_03 AC 26 ms
10,112 KB
testcase_04 AC 388 ms
24,064 KB
testcase_05 AC 557 ms
32,128 KB
testcase_06 AC 577 ms
31,872 KB
testcase_07 AC 949 ms
165,504 KB
testcase_08 AC 562 ms
32,000 KB
testcase_09 AC 740 ms
33,032 KB
testcase_10 AC 316 ms
17,920 KB
testcase_11 AC 291 ms
17,152 KB
testcase_12 AC 71 ms
11,136 KB
testcase_13 AC 349 ms
18,560 KB
testcase_14 AC 204 ms
14,976 KB
testcase_15 AC 24 ms
10,112 KB
testcase_16 AC 29 ms
10,240 KB
testcase_17 AC 199 ms
14,848 KB
testcase_18 AC 233 ms
15,872 KB
testcase_19 AC 81 ms
11,520 KB
testcase_20 AC 148 ms
13,568 KB
testcase_21 AC 281 ms
17,152 KB
testcase_22 AC 114 ms
12,544 KB
testcase_23 AC 26 ms
10,112 KB
testcase_24 AC 25 ms
10,112 KB
testcase_25 AC 26 ms
10,240 KB
testcase_26 AC 25 ms
10,112 KB
testcase_27 AC 29 ms
10,240 KB
testcase_28 AC 25 ms
10,112 KB
testcase_29 AC 24 ms
10,112 KB
testcase_30 AC 24 ms
10,112 KB
testcase_31 AC 23 ms
10,112 KB
testcase_32 AC 24 ms
10,112 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