結果

問題 No.179 塗り分け
ユーザー maspy
提出日時 2020-02-02 13:43:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-18 20:42:27
合計ジャッジ時間 4,417 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

H,W = map(int,readline().split())
data = ''.join(read().decode().split())

def test(a,b):
    if a==b==0:
        return False
    close = [0] * (H*W)
    for x,y in itertools.product(range(H), range(W)):
        ind = W*x + y
        if close[ind]:
            continue
        if data[ind] == '.':
            continue
        x1,y1 = x+a, y+b
        if x1 >= H or y1 < 0 or y1 >= W:
            return False
        ind1 = W*x1 + y1
        if data[ind1] == '.':
            return False
        close[ind] = 1
        close[ind1] = 1
    return True

answer = 'YES' if any(test(a,b) for a in range(51) for b in range(-51,51)) else 'NO'
print(answer)
0