結果

問題 No.2639 Longest Increasing Walk
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2024-03-20 15:37:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 115,268 KB
最終ジャッジ日時 2024-03-20 15:37:34
合計ジャッジ時間 6,620 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
63,672 KB
testcase_01 AC 49 ms
61,540 KB
testcase_02 AC 49 ms
63,672 KB
testcase_03 AC 49 ms
61,540 KB
testcase_04 AC 154 ms
97,348 KB
testcase_05 AC 223 ms
115,268 KB
testcase_06 AC 225 ms
114,628 KB
testcase_07 AC 264 ms
114,500 KB
testcase_08 AC 236 ms
115,140 KB
testcase_09 AC 286 ms
115,140 KB
testcase_10 AC 210 ms
96,196 KB
testcase_11 AC 204 ms
95,684 KB
testcase_12 AC 103 ms
79,156 KB
testcase_13 AC 265 ms
99,396 KB
testcase_14 AC 175 ms
90,180 KB
testcase_15 AC 50 ms
63,672 KB
testcase_16 AC 88 ms
77,920 KB
testcase_17 AC 166 ms
89,540 KB
testcase_18 AC 175 ms
90,820 KB
testcase_19 AC 108 ms
79,908 KB
testcase_20 AC 142 ms
85,188 KB
testcase_21 AC 219 ms
94,660 KB
testcase_22 AC 133 ms
84,036 KB
testcase_23 AC 63 ms
69,004 KB
testcase_24 AC 62 ms
69,128 KB
testcase_25 AC 76 ms
73,972 KB
testcase_26 AC 51 ms
63,672 KB
testcase_27 AC 79 ms
75,628 KB
testcase_28 AC 49 ms
61,540 KB
testcase_29 AC 49 ms
63,672 KB
testcase_30 AC 50 ms
63,668 KB
testcase_31 AC 50 ms
63,672 KB
testcase_32 AC 49 ms
63,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param("max_unroll_recursion=-1")
from collections import *
from functools import *
from itertools import *
from heapq import *
import sys, math,random,time
# input = sys.stdin.readline

H,W = map(int,input().split())
A = [tuple(map(int,input().split())) for _ in range(H)]

def nb(x,y):
    tmp = []
    if x+1<H:
        tmp.append((x+1,y))
    if x-1>=0:
        tmp.append((x-1,y))
    if y+1<W:
        tmp.append((x,y+1))
    if y-1>=0:
        tmp.append((x,y-1))
    return tmp
N = H*W
e = [[] for _ in range(N)]
ind = [0]*N
for i in range(H):
    for j in range(W):
        for ix,iy in nb(i,j):
            if A[i][j]<A[ix][iy]:
                e[W*i+j].append(W*ix+iy)
                ind[W*ix+iy] += 1

val = [-1]*N
v = deque()
for i in range(N):
    if ind[i]==0:
        val[i] = 1
        v.append(i)

while v:
    x = v.popleft()
    for ix in e[x]:

        val[ix] = max(val[ix],val[x]+1)
        ind[ix] -= 1
        if ind[ix]==0:
            v.append(ix)
print(max(val))
0