結果

問題 No.2639 Longest Increasing Walk
ユーザー hato336hato336
提出日時 2024-02-19 21:27:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,094 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 133,080 KB
最終ジャッジ日時 2024-02-19 21:27:16
合計ジャッジ時間 14,440 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
85,048 KB
testcase_01 AC 110 ms
85,048 KB
testcase_02 AC 106 ms
85,048 KB
testcase_03 AC 104 ms
85,048 KB
testcase_04 AC 793 ms
133,080 KB
testcase_05 AC 933 ms
129,680 KB
testcase_06 AC 778 ms
132,596 KB
testcase_07 AC 1,084 ms
126,980 KB
testcase_08 AC 917 ms
129,784 KB
testcase_09 AC 1,094 ms
129,000 KB
testcase_10 AC 710 ms
110,752 KB
testcase_11 AC 634 ms
108,080 KB
testcase_12 AC 203 ms
92,472 KB
testcase_13 AC 723 ms
112,412 KB
testcase_14 AC 464 ms
103,352 KB
testcase_15 AC 107 ms
85,048 KB
testcase_16 AC 159 ms
89,784 KB
testcase_17 AC 450 ms
103,096 KB
testcase_18 AC 559 ms
105,620 KB
testcase_19 AC 232 ms
93,624 KB
testcase_20 AC 356 ms
98,872 KB
testcase_21 AC 661 ms
108,272 KB
testcase_22 AC 299 ms
97,336 KB
testcase_23 AC 132 ms
89,144 KB
testcase_24 AC 132 ms
89,272 KB
testcase_25 AC 155 ms
89,656 KB
testcase_26 AC 114 ms
85,048 KB
testcase_27 AC 156 ms
89,656 KB
testcase_28 AC 113 ms
85,048 KB
testcase_29 AC 109 ms
85,048 KB
testcase_30 AC 108 ms
85,048 KB
testcase_31 AC 108 ms
85,048 KB
testcase_32 AC 109 ms
85,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
input = sys.stdin.readline

#alist = list(map(int,input().split()))
#alist = []
#s = input()
h,w = map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
grid = [list(map(int,input().split())) for i in range(h)]
dp = [[1 for i in range(w)] for j in range(h)]
hq = []
for i in range(h):
    for j in range(w):
        heapq.heappush(hq,(grid[i][j],i,j))
dxy = [[-1,0],[1,0],[0,-1],[0,1]]
while hq:
    x,i,j = heapq.heappop(hq)
    for dx,dy in dxy:
        if 0 <= i+dx < h and 0 <= j+dy < w and grid[i+dx][j+dy] > x:
            dp[i+dx][j+dy] = max(dp[i+dx][j+dy],dp[i][j]+1)
ans = 0
for i in dp:
    ans = max(ans,max(i))
print(ans)
0