結果
問題 | No.2412 YOU Grow Bigger! |
ユーザー | sotanishy |
提出日時 | 2023-08-11 23:19:09 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,601 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 76,416 KB |
最終ジャッジ日時 | 2024-04-29 14:29:52 |
合計ジャッジ時間 | 3,253 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
52,352 KB |
testcase_01 | AC | 42 ms
52,352 KB |
testcase_02 | AC | 51 ms
59,520 KB |
testcase_03 | AC | 83 ms
72,960 KB |
testcase_04 | RE | - |
testcase_05 | AC | 89 ms
74,496 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 111 ms
76,288 KB |
testcase_09 | AC | 60 ms
63,360 KB |
testcase_10 | AC | 61 ms
64,384 KB |
testcase_11 | AC | 53 ms
60,672 KB |
testcase_12 | RE | - |
testcase_13 | AC | 63 ms
64,640 KB |
testcase_14 | AC | 53 ms
60,800 KB |
testcase_15 | RE | - |
testcase_16 | AC | 61 ms
63,744 KB |
testcase_17 | RE | - |
testcase_18 | AC | 86 ms
73,856 KB |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | WA | - |
testcase_22 | AC | 69 ms
66,048 KB |
testcase_23 | RE | - |
testcase_24 | AC | 108 ms
76,416 KB |
testcase_25 | WA | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | AC | 73 ms
68,352 KB |
testcase_29 | RE | - |
testcase_30 | WA | - |
ソースコード
import sys input = sys.stdin.readline H, W = map(int, input().split()) S = [input().rstrip() for _ in range(H)] reachable1 = [[0] * W for _ in range(W)] st = [] for i in range(H): for j in range(W): if S[i][j] == '#' and (i >= H-3 or j < 3): reachable1[i][j] = 1 st.append((i, j)) while st: i, j = st.pop() for ni in range(i-3, i+4): for nj in range(j-3, j+4): if (ni, nj) != (i, j) and 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '#' and not reachable1[ni][nj]: reachable1[ni][nj] = 1 st.append((ni, nj)) reachable2 = [[0] * W for _ in range(W)] st = [] for i in range(H): for j in range(W): if S[i][j] == '#' and (i < 3 or j >= W-3): reachable2[i][j] = 1 st.append((i, j)) while st: i, j = st.pop() for ni in range(i-3, i+4): for nj in range(j-3, j+4): if (ni, nj) != (i, j) and 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '#' and not reachable2[ni][nj]: reachable2[ni][nj] = 1 st.append((ni, nj)) for i in range(H): for j in range(W): if reachable1[i][j] and reachable2[i][j]: print(0) exit() for i in range(H): for j in range(W): r1 = r2 = 0 for ni in range(i-3, i+4): for nj in range(j-3, j+4): if (ni, nj) != (i, j) and 0 <= ni < H and 0 <= nj < W: r1 |= reachable1[ni][nj] r2 |= reachable2[ni][nj] if r1 and r2: print(1) exit() print(2)