結果

問題 No.179 塗り分け
コンテスト
ユーザー rin204
提出日時 2022-01-20 09:08:45
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 60 ms / 3,000 ms
コード長 688 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 266 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2026-05-17 07:28:59
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

h, w = map(int, input().split())
S = [input() for _ in range(h)]

X = []
Y = []
dic = {}
for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            dic[i * 100 + j] = len(X)
            X.append(i)
            Y.append(j)
            
l = len(X)
if l % 2 == 1:
    print("NO")
    exit()
    
i = 0
for j in range(i + 1, l):
    di = X[j] - X[i]
    dj = Y[j] - Y[i]
    used = [False] * l
    for k in range(l):
        if used[k]:
            continue
        ni = X[k] + di
        nj = Y[k] + dj
        if ni * 100 + nj not in dic:
            break
        x = dic[ni * 100 + nj]
        used[x] = True
    else:
        print("YES")
        exit()
print("NO")
0