結果
問題 | No.86 TVザッピング(2) |
ユーザー | 👑 cologne |
提出日時 | 2022-01-27 15:05:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,366 bytes |
コンパイル時間 | 1,645 ms |
コンパイル使用メモリ | 87,084 KB |
実行使用メモリ | 76,712 KB |
最終ジャッジ日時 | 2023-08-26 15:22:43 |
合計ジャッジ時間 | 3,899 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
71,384 KB |
testcase_01 | AC | 67 ms
71,228 KB |
testcase_02 | AC | 65 ms
71,636 KB |
testcase_03 | AC | 64 ms
71,224 KB |
testcase_04 | AC | 65 ms
71,364 KB |
testcase_05 | AC | 68 ms
71,368 KB |
testcase_06 | AC | 62 ms
71,248 KB |
testcase_07 | AC | 67 ms
71,384 KB |
testcase_08 | AC | 69 ms
75,368 KB |
testcase_09 | AC | 78 ms
75,744 KB |
testcase_10 | AC | 74 ms
76,448 KB |
testcase_11 | AC | 64 ms
71,464 KB |
testcase_12 | AC | 65 ms
71,220 KB |
testcase_13 | AC | 63 ms
71,380 KB |
testcase_14 | WA | - |
testcase_15 | AC | 75 ms
76,372 KB |
testcase_16 | AC | 76 ms
76,496 KB |
testcase_17 | WA | - |
testcase_18 | AC | 68 ms
75,640 KB |
testcase_19 | AC | 67 ms
75,520 KB |
testcase_20 | AC | 64 ms
71,468 KB |
testcase_21 | AC | 75 ms
76,432 KB |
testcase_22 | AC | 65 ms
71,616 KB |
testcase_23 | AC | 72 ms
75,764 KB |
testcase_24 | AC | 63 ms
71,252 KB |
testcase_25 | AC | 63 ms
71,380 KB |
testcase_26 | AC | 64 ms
71,564 KB |
testcase_27 | AC | 63 ms
71,452 KB |
testcase_28 | AC | 65 ms
71,616 KB |
testcase_29 | AC | 76 ms
76,344 KB |
testcase_30 | AC | 66 ms
71,232 KB |
testcase_31 | AC | 66 ms
71,144 KB |
testcase_32 | AC | 64 ms
71,468 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 == mini: 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()