結果
問題 | No.2639 Longest Increasing Walk |
ユーザー | satama123 |
提出日時 | 2024-02-19 21:48:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 88,200 KB |
最終ジャッジ日時 | 2024-02-19 21:48:12 |
合計ジャッジ時間 | 5,293 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
55,600 KB |
testcase_01 | AC | 37 ms
55,600 KB |
testcase_02 | AC | 37 ms
55,600 KB |
testcase_03 | AC | 37 ms
55,600 KB |
testcase_04 | AC | 140 ms
88,200 KB |
testcase_05 | AC | 157 ms
82,568 KB |
testcase_06 | AC | 175 ms
82,568 KB |
testcase_07 | AC | 155 ms
82,568 KB |
testcase_08 | AC | 156 ms
82,440 KB |
testcase_09 | AC | 162 ms
82,696 KB |
testcase_10 | AC | 140 ms
80,392 KB |
testcase_11 | AC | 133 ms
79,752 KB |
testcase_12 | AC | 80 ms
76,824 KB |
testcase_13 | AC | 140 ms
80,904 KB |
testcase_14 | AC | 134 ms
78,740 KB |
testcase_15 | AC | 37 ms
55,600 KB |
testcase_16 | AC | 64 ms
72,912 KB |
testcase_17 | AC | 116 ms
78,984 KB |
testcase_18 | AC | 120 ms
79,496 KB |
testcase_19 | AC | 86 ms
77,104 KB |
testcase_20 | AC | 103 ms
78,228 KB |
testcase_21 | AC | 131 ms
79,880 KB |
testcase_22 | AC | 95 ms
77,440 KB |
testcase_23 | AC | 54 ms
68,352 KB |
testcase_24 | AC | 53 ms
68,356 KB |
testcase_25 | AC | 86 ms
70,832 KB |
testcase_26 | AC | 43 ms
55,600 KB |
testcase_27 | AC | 63 ms
70,828 KB |
testcase_28 | AC | 37 ms
55,600 KB |
testcase_29 | AC | 41 ms
55,600 KB |
testcase_30 | AC | 51 ms
55,600 KB |
testcase_31 | AC | 39 ms
55,600 KB |
testcase_32 | AC | 42 ms
55,600 KB |
ソースコード
from collections import deque H, W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] indeg = [0] * (H * W) dh = [0, 1, 0, -1] dw = [1, 0, -1, 0] for h in range(H): for w in range(W): for k in range(4): nh = h + dh[k] nw = w + dw[k] if nh < 0 or nh >= H or nw < 0 or nw >= W : continue if A[h][w] < A[nh][nw]: indeg[nh * W + nw] += 1 dp = [0] * (H * W) nxt = deque() for i in range(H * W): if indeg[i] == 0 : nxt.append(i) while nxt: pos = nxt.popleft() h = pos // W w = pos % W for k in range(4): nh = h + dh[k] nw = w + dw[k] if nh < 0 or nh >= H or nw < 0 or nw >= W : continue if A[h][w] < A[nh][nw]: t = nh * W + nw indeg[t] -= 1 if indeg[t] == 0 : nxt.append((t)) dp[t] = max(dp[t], dp[pos] + 1) print(max(dp) + 1)