結果

問題 No.179 塗り分け
ユーザー MitI_7
提出日時 2015-12-27 13:27:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-10-03 03:13:06
合計ジャッジ時間 5,509 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 5 WA * 1 TLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(d, r, sharps):
    find = set()
    for y, x in sharps:
        if (y, x) in find:
            continue
        ny = y + d
        nx = x + r
        if (ny, nx) in sharps:
            find.add((y, x))
            find.add((ny, nx))
        else:
            return False

    return len(find) == len(sharps)


def main():
    h, w = map(int, input().split())

    sharps = []
    for y in range(h):
        line = input()
        for x in range(len(line)):
            if line[x] == '#':
                sharps.append((y, x))

    for d in range(50):
        for r in range(-50, 50):
            if d == 0 and r == 0:
                continue
            if func(d, r, sharps):
                print("YES")
                return
    print("NO")
    
if __name__ == '__main__':
    main()
0