結果

問題 No.179 塗り分け
ユーザー FromBooskaFromBooska
提出日時 2023-10-15 20:02:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 366 ms / 3,000 ms
コード長 1,206 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 78,552 KB
最終ジャッジ日時 2023-10-15 20:02:29
合計ジャッジ時間 10,835 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,564 KB
testcase_01 AC 70 ms
71,252 KB
testcase_02 AC 74 ms
75,828 KB
testcase_03 AC 71 ms
71,364 KB
testcase_04 AC 87 ms
76,664 KB
testcase_05 AC 71 ms
71,612 KB
testcase_06 AC 121 ms
77,868 KB
testcase_07 AC 77 ms
75,652 KB
testcase_08 AC 241 ms
77,736 KB
testcase_09 AC 250 ms
77,924 KB
testcase_10 AC 331 ms
77,836 KB
testcase_11 AC 323 ms
77,944 KB
testcase_12 AC 297 ms
77,868 KB
testcase_13 AC 77 ms
75,952 KB
testcase_14 AC 77 ms
76,340 KB
testcase_15 AC 69 ms
71,408 KB
testcase_16 AC 69 ms
71,416 KB
testcase_17 AC 70 ms
71,108 KB
testcase_18 AC 304 ms
77,964 KB
testcase_19 AC 302 ms
78,552 KB
testcase_20 AC 76 ms
75,884 KB
testcase_21 AC 74 ms
75,972 KB
testcase_22 AC 366 ms
78,040 KB
testcase_23 AC 317 ms
77,948 KB
testcase_24 AC 222 ms
78,160 KB
testcase_25 AC 229 ms
77,984 KB
testcase_26 AC 256 ms
78,280 KB
testcase_27 AC 280 ms
77,844 KB
testcase_28 AC 314 ms
78,232 KB
testcase_29 AC 325 ms
78,096 KB
testcase_30 AC 327 ms
78,228 KB
testcase_31 AC 335 ms
78,188 KB
testcase_32 AC 354 ms
78,152 KB
testcase_33 AC 337 ms
77,980 KB
testcase_34 AC 359 ms
77,772 KB
testcase_35 AC 357 ms
77,868 KB
testcase_36 AC 71 ms
71,256 KB
testcase_37 AC 70 ms
71,484 KB
testcase_38 AC 71 ms
71,256 KB
testcase_39 AC 71 ms
71,256 KB
testcase_40 AC 76 ms
76,344 KB
testcase_41 AC 69 ms
71,140 KB
testcase_42 AC 75 ms
75,880 KB
testcase_43 AC 107 ms
77,328 KB
testcase_44 AC 129 ms
77,320 KB
testcase_45 AC 93 ms
76,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 黒を平行移動2グループに分けられるか
# 平行移動(di, dj)で全探索
# WA出た、djはマイナスもあるな
# 黒が0のときもダメだ、黒のカウントが2以上の偶数チェック必要

H, W = map(int, input().split())
S = []
S_num = []
black_count = 0
for i in range(H):
    temp = input()
    S.append(temp)
    black_count += temp.count('#')
    s = []
    for t in temp:
        if t == '.':
            s.append(0)
        else:
            s.append(1)
    S_num.append(s)
    
if black_count == 0 or black_count%2 == 1:
    print('NO')
    exit()

ans = 'NO'
for di in range(0, H):
    for dj in range(1-W, W):
        if (di, dj) == (0, 0):
            continue
        
        #print('di', di, 'dj', dj)
        color = [[0]*W for i in range(H)]
        for i in range(H):
            for j in range(W):
                #print('i', i, 'j', j)
                if S_num[i][j] == 1 and 0<=i+di<H and 0<=j+dj<W:
                    if color[i][j] == 0 and color[i+di][j+dj] == 0:
                        color[i][j] = 1
                        color[i+di][j+dj] = 1
        if S_num == color:
            #print(di, dj, color)
            ans = 'YES'
print(ans)   
0