結果
問題 | No.86 TVザッピング(2) |
ユーザー | tnodino |
提出日時 | 2022-03-05 21:00:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,475 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-20 03:27:33 |
合計ジャッジ時間 | 3,274 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 42 ms
11,136 KB |
testcase_02 | AC | 47 ms
11,008 KB |
testcase_03 | AC | 39 ms
11,008 KB |
testcase_04 | AC | 36 ms
11,008 KB |
testcase_05 | AC | 38 ms
10,880 KB |
testcase_06 | AC | 35 ms
11,008 KB |
testcase_07 | AC | 41 ms
11,008 KB |
testcase_08 | AC | 52 ms
11,008 KB |
testcase_09 | AC | 40 ms
11,136 KB |
testcase_10 | AC | 39 ms
11,136 KB |
testcase_11 | AC | 29 ms
10,880 KB |
testcase_12 | AC | 28 ms
11,008 KB |
testcase_13 | AC | 27 ms
10,880 KB |
testcase_14 | AC | 36 ms
11,136 KB |
testcase_15 | AC | 36 ms
11,136 KB |
testcase_16 | AC | 36 ms
11,136 KB |
testcase_17 | WA | - |
testcase_18 | AC | 28 ms
10,880 KB |
testcase_19 | AC | 30 ms
11,008 KB |
testcase_20 | AC | 29 ms
10,880 KB |
testcase_21 | AC | 384 ms
11,136 KB |
testcase_22 | AC | 29 ms
11,008 KB |
testcase_23 | AC | 38 ms
11,264 KB |
testcase_24 | AC | 27 ms
10,880 KB |
testcase_25 | AC | 28 ms
11,008 KB |
testcase_26 | AC | 27 ms
11,008 KB |
testcase_27 | AC | 27 ms
11,008 KB |
testcase_28 | AC | 29 ms
11,008 KB |
testcase_29 | AC | 39 ms
11,136 KB |
testcase_30 | AC | 28 ms
11,008 KB |
testcase_31 | AC | 28 ms
11,008 KB |
testcase_32 | AC | 29 ms
11,008 KB |
ソースコード
def CheckPoint(N, M, L): P = [] dx = [0, 0, 1, 1] dy = [0, 1, 0, 1] for x in range(N+1): for y in range(M+1): C = [] flg = [False] * 4 cnt = 0 for i in range(4): nx,my = x + dx[i], y + dy[i] if L[nx][my] == '.': C.append((nx, my)) flg[i] = True cnt += 1 if cnt % 2 == 0: continue if cnt == 1: X = C[0] elif cnt == 3: if flg[0] and flg[1] and flg[2]: X = C[0] elif flg[0] and flg[1] and flg[3]: X = C[1] elif flg[0] and flg[2] and flg[3]: X = C[1] elif flg[1] and flg[2] and flg[3]: X = C[2] if not X in P: P.append(X) return P def Check4(L, P): def dfs(x, y, gx, gy, dx, dy): if x == gx and y == gy: return if L[x][y] == '#': print('NO') exit() L[x][y] = '#' dfs(x + dx, y + dy, gx, gy, dx, dy) X,Y = [list(i) for i in zip(*P)] dfs(X[0], Y[0], X[2], Y[2], 1, 0) dfs(X[2], Y[2], X[3], Y[3], 0, 1) dfs(X[3], Y[3], X[1], Y[1], -1, 0) dfs(X[1], Y[1], X[0], Y[0], 0, -1) return L def Check6(L, P): def dfs(x, y, gx, gy, dx, dy): if x == gx and y == gy: return if L[x][y] == '#': print('NO') exit() L[x][y] = '#' dfs(x + dx, y + dy, gx, gy, dx, dy) X,Y = [list(i) for i in zip(*P)] dfs(X[2], Y[2], X[1], Y[1], -1, 0) dfs(X[1], Y[1], X[0], Y[0], 0, -1) dfs(X[0], Y[0], X[4], Y[4], 1, 0) dfs(X[4], Y[4], X[5], Y[5], 0, 1) dfs(X[5], Y[5], X[3], Y[3], -1, 0) dfs(X[3], Y[3], X[2], Y[2], 0, -1) return L def CheckDots(N, M, L): for x in range(N+1): for y in range(M+1): if L[x][y] == '.': return False return True N,M = map(int,input().split()) A = [list(input()) for _ in range(N)] B = [['#'] * (M+2) for _ in range(N+2)] for i in range(N): for j in range(M): B[i+1][j+1] = A[i][j] P = CheckPoint(N, M, B) if len(P) != 4 and len(P) != 6: print('NO') exit() if len(P) == 4: B = Check4(B, P) elif len(P) == 6: B = Check6(B, P) if CheckDots(N, M, B): print('YES') else: print('NO')