結果
問題 | No.86 TVザッピング(2) |
ユーザー | 👑 cologne |
提出日時 | 2022-01-27 14:44:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,426 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 87,108 KB |
実行使用メモリ | 76,092 KB |
最終ジャッジ日時 | 2023-08-26 15:04:15 |
合計ジャッジ時間 | 3,733 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,488 KB |
testcase_01 | WA | - |
testcase_02 | AC | 66 ms
71,404 KB |
testcase_03 | AC | 67 ms
71,168 KB |
testcase_04 | AC | 67 ms
71,360 KB |
testcase_05 | AC | 70 ms
71,456 KB |
testcase_06 | AC | 68 ms
71,544 KB |
testcase_07 | AC | 67 ms
71,548 KB |
testcase_08 | AC | 70 ms
75,700 KB |
testcase_09 | AC | 72 ms
76,092 KB |
testcase_10 | AC | 72 ms
76,092 KB |
testcase_11 | AC | 69 ms
71,368 KB |
testcase_12 | AC | 66 ms
71,168 KB |
testcase_13 | AC | 67 ms
71,320 KB |
testcase_14 | AC | 74 ms
75,564 KB |
testcase_15 | AC | 70 ms
75,360 KB |
testcase_16 | AC | 73 ms
75,516 KB |
testcase_17 | AC | 68 ms
71,312 KB |
testcase_18 | AC | 68 ms
71,448 KB |
testcase_19 | AC | 66 ms
71,352 KB |
testcase_20 | AC | 66 ms
71,444 KB |
testcase_21 | AC | 73 ms
76,024 KB |
testcase_22 | AC | 68 ms
71,360 KB |
testcase_23 | AC | 74 ms
75,920 KB |
testcase_24 | AC | 68 ms
71,544 KB |
testcase_25 | AC | 67 ms
71,448 KB |
testcase_26 | AC | 67 ms
71,312 KB |
testcase_27 | AC | 68 ms
71,492 KB |
testcase_28 | AC | 66 ms
71,160 KB |
testcase_29 | AC | 71 ms
75,968 KB |
testcase_30 | AC | 66 ms
71,576 KB |
testcase_31 | AC | 66 ms
71,452 KB |
testcase_32 | AC | 68 ms
71,700 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 maxi == mini or maxj == minj: print('NO') return 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()