結果

問題 No.2639 Longest Increasing Walk
ユーザー chineristACchineristAC
提出日時 2024-02-19 22:12:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,968 KB
最終ジャッジ日時 2024-02-19 22:12:12
合計ジャッジ時間 5,585 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
56,236 KB
testcase_01 AC 41 ms
56,236 KB
testcase_02 AC 39 ms
56,236 KB
testcase_03 AC 38 ms
56,236 KB
testcase_04 AC 153 ms
106,536 KB
testcase_05 AC 164 ms
108,328 KB
testcase_06 AC 167 ms
108,200 KB
testcase_07 AC 220 ms
108,072 KB
testcase_08 AC 172 ms
108,584 KB
testcase_09 AC 249 ms
108,968 KB
testcase_10 AC 254 ms
88,236 KB
testcase_11 AC 246 ms
91,816 KB
testcase_12 AC 83 ms
78,548 KB
testcase_13 AC 268 ms
96,296 KB
testcase_14 AC 183 ms
86,952 KB
testcase_15 AC 41 ms
56,236 KB
testcase_16 AC 57 ms
69,384 KB
testcase_17 AC 139 ms
86,952 KB
testcase_18 AC 205 ms
89,640 KB
testcase_19 AC 97 ms
79,656 KB
testcase_20 AC 138 ms
81,832 KB
testcase_21 AC 253 ms
90,024 KB
testcase_22 AC 115 ms
81,332 KB
testcase_23 AC 49 ms
66,660 KB
testcase_24 AC 49 ms
66,648 KB
testcase_25 AC 54 ms
69,400 KB
testcase_26 AC 40 ms
56,236 KB
testcase_27 AC 55 ms
69,396 KB
testcase_28 AC 39 ms
56,236 KB
testcase_29 AC 38 ms
56,236 KB
testcase_30 AC 38 ms
56,236 KB
testcase_31 AC 40 ms
56,236 KB
testcase_32 AC 42 ms
56,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

H,W = mi()
A = [li() for i in range(H)]

INF = 10**9
dp = [[-INF]*W for i in range(H)]

idx = [(i,j) for i in range(H) for j in range(W)]
idx.sort(key=lambda x:A[x[0]][x[1]])

for (i,j) in idx[::-1]:
    dp[i][j] = 1
    for dx,dy in [(-1,0),(0,1),(1,0),(0,-1)]:
        ni,nj = i+dx,j+dy
        if 0 <= ni < H and 0 <= nj < W and dp[ni][nj]!=-INF and A[ni][nj] > A[i][j]:
            dp[i][j] = max(dp[i][j],dp[ni][nj]+1)

res = max(max(dp[i]) for i in range(H))
print(res)
0