結果
問題 | No.1668 Grayscale |
ユーザー | tamato |
提出日時 | 2021-09-03 22:38:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,197 ms / 4,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 217,328 KB |
最終ジャッジ日時 | 2024-05-09 05:32:20 |
合計ジャッジ時間 | 5,472 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,652 KB |
testcase_01 | AC | 35 ms
52,800 KB |
testcase_02 | AC | 35 ms
53,360 KB |
testcase_03 | AC | 35 ms
53,132 KB |
testcase_04 | AC | 36 ms
53,084 KB |
testcase_05 | AC | 38 ms
54,000 KB |
testcase_06 | AC | 485 ms
217,328 KB |
testcase_07 | AC | 483 ms
216,940 KB |
testcase_08 | AC | 180 ms
155,080 KB |
testcase_09 | AC | 1,197 ms
213,572 KB |
testcase_10 | AC | 602 ms
128,340 KB |
testcase_11 | AC | 45 ms
62,284 KB |
testcase_12 | AC | 53 ms
67,772 KB |
testcase_13 | AC | 92 ms
84,500 KB |
testcase_14 | AC | 206 ms
101,748 KB |
testcase_15 | AC | 136 ms
87,652 KB |
testcase_16 | AC | 111 ms
82,740 KB |
testcase_17 | AC | 85 ms
81,460 KB |
testcase_18 | AC | 35 ms
53,748 KB |
testcase_19 | AC | 35 ms
53,924 KB |
testcase_20 | AC | 51 ms
67,352 KB |
testcase_21 | AC | 61 ms
70,532 KB |
testcase_22 | AC | 34 ms
53,312 KB |
testcase_23 | AC | 35 ms
52,980 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline d = [(0, 1), (0, -1), (-1, 0), (1, 0)] H, W, N = map(int, input().split()) C = [] for _ in range(H): C.append(list(map(int, input().split()))) P = [[] for _ in range(N+1)] for h in range(H): for w in range(W): P[C[h][w]].append((h, w)) ans = 1 prev = 1 for c in range(2, N+1): flg = 0 for h, w in P[c]: for dh, dw in d: h_new, w_new = h + dh, w + dw if 0 <= h_new < H and 0 <= w_new < W: if C[h_new][w_new] == prev: flg = 1 if flg: ans += 1 prev = c else: for h, w in P[c]: C[h][w] = prev print(ans) if __name__ == '__main__': main()