結果

問題 No.2639 Longest Increasing Walk
ユーザー rlangevinrlangevin
提出日時 2024-02-21 12:16:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 627 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 112,916 KB
最終ジャッジ日時 2024-02-21 12:16:37
合計ジャッジ時間 8,516 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 46 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 196 ms
111,076 KB
testcase_05 AC 229 ms
112,916 KB
testcase_06 AC 229 ms
111,620 KB
testcase_07 AC 439 ms
112,412 KB
testcase_08 AC 247 ms
111,724 KB
testcase_09 AC 437 ms
111,812 KB
testcase_10 AC 598 ms
97,980 KB
testcase_11 AC 515 ms
93,324 KB
testcase_12 AC 101 ms
73,508 KB
testcase_13 AC 627 ms
101,416 KB
testcase_14 AC 343 ms
90,764 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 AC 55 ms
64,580 KB
testcase_17 AC 228 ms
90,636 KB
testcase_18 AC 423 ms
94,476 KB
testcase_19 AC 130 ms
80,508 KB
testcase_20 AC 249 ms
83,212 KB
testcase_21 AC 503 ms
92,192 KB
testcase_22 AC 220 ms
82,060 KB
testcase_23 AC 48 ms
62,096 KB
testcase_24 AC 48 ms
62,096 KB
testcase_25 AC 62 ms
69,036 KB
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 62 ms
69,032 KB
testcase_28 AC 37 ms
53,460 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 36 ms
53,460 KB
testcase_31 AC 36 ms
53,460 KB
testcase_32 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
A = []
D = []
for i in range(H):
    A.append(list(map(int, input().split())))
    for j in range(W):
        D.append((A[i][j], i, j))
        
D.sort()
B = [[1] * W for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for a, px, py in D:
    for k in range(4):
        x = px + dx[k]
        y = py + dy[k]
        if x < 0 or x > H - 1 or y < 0 or y > W - 1:
            continue
        if A[x][y] >= a:
            continue
        B[px][py] = max(B[px][py], B[x][y] + 1)
        
print(max([max(B[i]) for i in range(H)]))        
0