結果
問題 | No.86 TVザッピング(2) |
ユーザー | 👑 cologne |
提出日時 | 2022-01-27 15:07:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 86 ms / 5,000 ms |
コード長 | 2,366 bytes |
コンパイル時間 | 437 ms |
コンパイル使用メモリ | 86,920 KB |
実行使用メモリ | 76,376 KB |
最終ジャッジ日時 | 2023-08-26 15:25:16 |
合計ジャッジ時間 | 4,384 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,244 KB |
testcase_01 | AC | 73 ms
71,244 KB |
testcase_02 | AC | 76 ms
71,304 KB |
testcase_03 | AC | 72 ms
71,180 KB |
testcase_04 | AC | 71 ms
70,908 KB |
testcase_05 | AC | 73 ms
71,092 KB |
testcase_06 | AC | 73 ms
71,356 KB |
testcase_07 | AC | 72 ms
71,296 KB |
testcase_08 | AC | 77 ms
75,424 KB |
testcase_09 | AC | 84 ms
75,764 KB |
testcase_10 | AC | 80 ms
76,296 KB |
testcase_11 | AC | 72 ms
71,240 KB |
testcase_12 | AC | 71 ms
71,296 KB |
testcase_13 | AC | 74 ms
71,092 KB |
testcase_14 | AC | 82 ms
75,464 KB |
testcase_15 | AC | 84 ms
76,328 KB |
testcase_16 | AC | 83 ms
76,268 KB |
testcase_17 | AC | 78 ms
75,428 KB |
testcase_18 | AC | 76 ms
75,252 KB |
testcase_19 | AC | 76 ms
75,252 KB |
testcase_20 | AC | 74 ms
71,088 KB |
testcase_21 | AC | 86 ms
76,376 KB |
testcase_22 | AC | 74 ms
71,396 KB |
testcase_23 | AC | 82 ms
75,672 KB |
testcase_24 | AC | 73 ms
71,492 KB |
testcase_25 | AC | 72 ms
71,336 KB |
testcase_26 | AC | 72 ms
71,300 KB |
testcase_27 | AC | 74 ms
71,272 KB |
testcase_28 | AC | 73 ms
71,532 KB |
testcase_29 | AC | 85 ms
76,304 KB |
testcase_30 | AC | 74 ms
71,272 KB |
testcase_31 | AC | 75 ms
71,444 KB |
testcase_32 | AC | 72 ms
71,480 KB |
ソースコード
import sys import math def input(): return sys.stdin.readline().rstrip() def check(A): N = len(A) M = len(A[0]) 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: return False if cnt != 2*(maxi-mini) + 2*(maxj-minj): return False 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(): return True 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: return False redi = i if cnt < 2: return False 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: return False redj = j if cnt < 2: return False if redi is None or redj is None: return False for i in range(N): for j in range(M): if A[i][j] == '.': if i == maxi: continue if j == minj: continue if i == mini and minj <= j <= redj: continue if i == redi and redj <= j <= maxj: continue if j == redj and mini <= i <= redi: continue if j == maxj and redi <= i <= maxi: continue return False return True def main(): N, M = map(int, input().split()) A = [input() for i in range(N)] for i in range(4): if check(A): print('YES') return *A, = zip(*A[::-1]) print('NO') if __name__ == '__main__': main()