結果

問題 No.1668 Grayscale
ユーザー rlangevinrlangevin
提出日時 2023-12-05 12:09:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 749 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 224,268 KB
最終ジャッジ日時 2023-12-05 12:10:04
合計ジャッジ時間 7,095 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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))

temp = [[0] * W for i in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
ans = 1
que = []
for i in range(N):
    D = []
    val = 0
    for x, y in G[i]:
        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 |= temp[nx][ny]
        D.append((x, y))
    ans += val
    if val:
        for x, y in que:
            temp[x][y] = 0
    for x, y in D:
        temp[x][y] = 1

    que.extend(D)

print(ans)
0