結果

問題 No.2639 Longest Increasing Walk
ユーザー KoiKoi
提出日時 2024-02-19 21:50:40
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 882 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 109,960 KB
最終ジャッジ日時 2024-02-19 21:50:46
合計ジャッジ時間 5,299 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,608 KB
testcase_01 AC 41 ms
55,608 KB
testcase_02 AC 41 ms
55,608 KB
testcase_03 AC 44 ms
55,608 KB
testcase_04 AC 138 ms
91,912 KB
testcase_05 AC 201 ms
109,960 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 AC 94 ms
78,892 KB
testcase_13 AC 180 ms
92,040 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 AC 64 ms
70,816 KB
testcase_28 AC 41 ms
55,608 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
H,W=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
G=[[] for _ in range(H*W)]
into_num=[0]*(H*W)
def xy_to_x_y(xy):
    return xy//H,xy%H
def x_y_to_xy(x,y):
    return x*H+y
dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(H):
    for j in range(W):
        for k in range(4):
            new_x=i+dx[k]
            new_y=j+dy[k]
            if(0<=new_x<H and 0<=new_y<W and A[i][j]<A[new_x][new_y]):
                ij=x_y_to_xy(i,j)
                new_xy=x_y_to_xy(new_x,new_y)
                G[ij].append(new_xy)
                into_num[new_xy]+=1
que=deque()
dp=[0]*(H*W)
for i in range(H*W):
    if(into_num[i]==0):
        que.append(i)
while len(que):
    p=que.popleft()
    for q in G[p]:
        dp[q]=max(dp[q],dp[p]+1)
        into_num[q]-=1
        if(into_num[q]==0):
            que.append(q)
print(max(dp)+1)
0