結果

問題 No.1668 Grayscale
ユーザー rlangevinrlangevin
提出日時 2023-12-05 08:55:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 265,856 KB
最終ジャッジ日時 2023-12-05 08:55:52
合計ジャッジ時間 10,934 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 39 ms
53,460 KB
testcase_06 WA -
testcase_07 AC 652 ms
216,824 KB
testcase_08 AC 1,156 ms
265,856 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 39 ms
53,460 KB
testcase_23 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
G = [[] for i in range(N)]
for i in range(H):
    C = list(map(int, input().split()))
    for j in range(W):
        G[C[j] - 1].append((i, j))

inf = 10 ** 18
temp = [[-inf] * W for i in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(N):
    dic = dict()
    for x, y in G[i]:
        val = 0
        for k in range(4):
            nx = x + dx[k]
            ny = y + dy[k]
            if nx < 0 or nx > H - 1 or ny < 0 or ny > W - 1:
                continue
            val = max(val, temp[nx][ny] + 1)
        dic[(x, y)] = val

    for x, y in G[i]:
        temp[x][y] = dic[(x, y)]

ans = 0
for i in range(H):
    ans = max(ans, max(temp[i]))

print(ans + 1)
0