結果
問題 | No.86 TVザッピング(2) |
ユーザー | 👑 cologne |
提出日時 | 2022-01-27 14:43:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,354 bytes |
コンパイル時間 | 1,511 ms |
コンパイル使用メモリ | 85,980 KB |
実行使用メモリ | 75,604 KB |
最終ジャッジ日時 | 2023-08-26 14:44:54 |
合計ジャッジ時間 | 5,093 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
70,908 KB |
testcase_01 | WA | - |
testcase_02 | AC | 63 ms
70,844 KB |
testcase_03 | AC | 66 ms
70,848 KB |
testcase_04 | AC | 64 ms
71,036 KB |
testcase_05 | AC | 63 ms
71,032 KB |
testcase_06 | AC | 62 ms
71,008 KB |
testcase_07 | AC | 63 ms
71,024 KB |
testcase_08 | AC | 72 ms
74,920 KB |
testcase_09 | AC | 74 ms
75,604 KB |
testcase_10 | AC | 70 ms
75,436 KB |
testcase_11 | AC | 64 ms
71,008 KB |
testcase_12 | WA | - |
testcase_13 | AC | 64 ms
71,240 KB |
testcase_14 | AC | 70 ms
75,000 KB |
testcase_15 | AC | 67 ms
75,112 KB |
testcase_16 | AC | 67 ms
75,140 KB |
testcase_17 | AC | 66 ms
70,832 KB |
testcase_18 | AC | 65 ms
70,952 KB |
testcase_19 | AC | 66 ms
70,992 KB |
testcase_20 | AC | 63 ms
70,832 KB |
testcase_21 | AC | 71 ms
75,408 KB |
testcase_22 | AC | 64 ms
70,984 KB |
testcase_23 | AC | 69 ms
75,332 KB |
testcase_24 | AC | 63 ms
71,012 KB |
testcase_25 | AC | 63 ms
70,676 KB |
testcase_26 | WA | - |
testcase_27 | AC | 63 ms
71,108 KB |
testcase_28 | AC | 64 ms
71,276 KB |
testcase_29 | AC | 69 ms
75,532 KB |
testcase_30 | AC | 64 ms
71,104 KB |
testcase_31 | AC | 66 ms
70,800 KB |
testcase_32 | AC | 65 ms
71,020 KB |
ソースコード
import sys import math def input(): return sys.stdin.readline().rstrip() def main(): N, M = map(int, input().split()) A = [input() for i in range(N)] mini = minj = math.inf maxi = maxj = -math.inf cnt = 0 for i in range(N): for j in range(M): if A[i][j] == '.': cnt += 1 mini, minj, maxi, maxj = \ min(mini, i), min(minj, j), max(maxi, i), max(maxj, j) if cnt != 2*(maxi-mini) + 2*(maxj-minj): print('NO') return def checkrect(): for i in range(mini, maxi+1): if A[i][minj] == '#' or A[i][maxj] == '#': return False for j in range(minj, maxj+1): if A[mini][j] == '#' or A[maxi][j] == '#': return False return True if checkrect(): print('YES') return redi = redj = None for i in range(mini+1, maxi): cnt = 0 for j in range(minj, maxj+1): if A[i][j] == '.': cnt += 1 if cnt > 2: if redi is not None: print('NO') return redi = i if cnt < 2: print('NO') return for j in range(minj+1, maxj): cnt = 0 for i in range(mini, maxi+1): if A[i][j] == '.': cnt += 1 if cnt > 2: if redj is not None: print('NO') return redj = j if cnt < 2: print('NO') return if redi is None or redj is None: print('NO') return def checku(): for i in range(mini, redi+1): if A[i][redj] == '#': return False return True def checkd(): for i in range(redi, maxi+1): if A[i][redj] == '#': return False return True def checkl(): for j in range(minj, redj+1): if A[redi][j] == '#': return False return True def checkr(): for j in range(redj, maxj+1): if A[redi][j] == '#': return False return True if (checku() or checkd()) and (checkl() or checkr()): print('YES') else: print('NO') if __name__ == '__main__': main()