結果

問題 No.2639 Longest Increasing Walk
ユーザー 👑 timitimi
提出日時 2024-02-19 21:59:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 137,076 KB
最終ジャッジ日時 2024-02-19 21:59:38
合計ジャッジ時間 5,679 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,588 KB
testcase_01 AC 31 ms
53,588 KB
testcase_02 AC 32 ms
53,588 KB
testcase_03 AC 33 ms
53,588 KB
testcase_04 AC 124 ms
91,708 KB
testcase_05 AC 280 ms
136,672 KB
testcase_06 AC 292 ms
136,044 KB
testcase_07 AC 325 ms
136,372 KB
testcase_08 AC 245 ms
137,064 KB
testcase_09 AC 327 ms
137,076 KB
testcase_10 AC 260 ms
111,716 KB
testcase_11 AC 226 ms
105,644 KB
testcase_12 AC 73 ms
81,560 KB
testcase_13 AC 266 ms
116,792 KB
testcase_14 AC 171 ms
102,464 KB
testcase_15 AC 35 ms
53,588 KB
testcase_16 AC 47 ms
66,668 KB
testcase_17 AC 89 ms
80,392 KB
testcase_18 AC 188 ms
104,240 KB
testcase_19 AC 83 ms
84,520 KB
testcase_20 AC 159 ms
92,764 KB
testcase_21 AC 227 ms
106,204 KB
testcase_22 AC 108 ms
86,676 KB
testcase_23 AC 43 ms
64,444 KB
testcase_24 AC 44 ms
64,444 KB
testcase_25 AC 55 ms
71,768 KB
testcase_26 AC 32 ms
53,588 KB
testcase_27 AC 55 ms
71,756 KB
testcase_28 AC 31 ms
53,588 KB
testcase_29 AC 30 ms
53,588 KB
testcase_30 AC 31 ms
53,588 KB
testcase_31 AC 32 ms
53,588 KB
testcase_32 AC 33 ms
53,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int, input().split())
A=[];B=[];D={}

for i in range(H):
  AA=list(map(int, input().split()))
  A.append(AA)
  for j in range(W):
    a=AA[j]
    if a not in D:
      D[a]=[]
      B.append(a)
    D[a].append((i,j))
B=sorted(B)

dp=[[1]*W for _ in range(H)]
dy,dx=[1,-1,0,0],[0,0,1,-1]
for b in B:
  if b==1:
    continue 
  for y,x in D[b]:
    for i in range(4):
      ny,nx=y+dy[i],x+dx[i]
      if 0<=ny<H and 0<=nx<W and A[ny][nx]<A[y][x]:
        dp[y][x]=max(dp[y][x],dp[ny][nx]+1)
ans=0
for h in range(H):
  for w in range(W):
    ans=max(ans,dp[h][w])
print(ans)
    
0