結果

問題 No.179 塗り分け
ユーザー gorugo30
提出日時 2021-03-16 23:15:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 437 ms / 3,000 ms
コード長 973 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-11-08 19:08:25
合計ジャッジ時間 10,104 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
grid = [input() for i in range(H)]

cnt = sum([grid[i].count("#") for i in range(H)])
if cnt < 2:
    print("NO")
    exit()
for tatehoukounoshift in range(-(H - 1), H):
    for yokohoukounoshift in range(-(W - 1), W):
        if tatehoukounoshift == yokohoukounoshift == 0:
            continue
        can = True
        used = [[False] * W for i in range(H)]
        for i in range(H):
            for j in range(W):
                if used[i][j] or grid[i][j] == ".":
                    continue
                if not (0 <= i + tatehoukounoshift < H and 0 <= j + yokohoukounoshift < W):
                    can = False
                    break
                if grid[i + tatehoukounoshift][j + yokohoukounoshift] == ".":
                    can = False
                used[i][j] = True
                used[i + tatehoukounoshift][j + yokohoukounoshift] = True
        if can:
            print("YES")
            exit()
print("NO")
0