結果

問題 No.179 塗り分け
ユーザー FromBooskaFromBooska
提出日時 2023-10-15 19:58:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,180 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 78,440 KB
最終ジャッジ日時 2023-10-15 19:58:33
合計ジャッジ時間 11,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,408 KB
testcase_01 AC 71 ms
71,120 KB
testcase_02 AC 75 ms
75,768 KB
testcase_03 AC 72 ms
71,420 KB
testcase_04 AC 82 ms
76,576 KB
testcase_05 AC 74 ms
71,252 KB
testcase_06 AC 124 ms
77,648 KB
testcase_07 AC 75 ms
75,880 KB
testcase_08 AC 246 ms
77,848 KB
testcase_09 AC 253 ms
77,716 KB
testcase_10 AC 371 ms
78,080 KB
testcase_11 AC 357 ms
78,104 KB
testcase_12 WA -
testcase_13 AC 77 ms
75,940 KB
testcase_14 AC 78 ms
76,520 KB
testcase_15 AC 71 ms
71,260 KB
testcase_16 AC 71 ms
71,624 KB
testcase_17 AC 70 ms
71,308 KB
testcase_18 AC 346 ms
77,976 KB
testcase_19 AC 326 ms
78,188 KB
testcase_20 AC 78 ms
75,808 KB
testcase_21 AC 76 ms
75,932 KB
testcase_22 AC 418 ms
78,272 KB
testcase_23 AC 361 ms
78,036 KB
testcase_24 AC 231 ms
78,032 KB
testcase_25 AC 229 ms
77,864 KB
testcase_26 AC 275 ms
78,440 KB
testcase_27 AC 321 ms
78,012 KB
testcase_28 AC 362 ms
77,964 KB
testcase_29 AC 375 ms
77,944 KB
testcase_30 AC 413 ms
78,268 KB
testcase_31 AC 425 ms
78,052 KB
testcase_32 AC 427 ms
78,232 KB
testcase_33 AC 393 ms
78,184 KB
testcase_34 AC 457 ms
78,380 KB
testcase_35 AC 394 ms
77,712 KB
testcase_36 AC 70 ms
71,368 KB
testcase_37 AC 71 ms
71,336 KB
testcase_38 AC 71 ms
71,332 KB
testcase_39 AC 98 ms
71,108 KB
testcase_40 AC 77 ms
76,344 KB
testcase_41 AC 71 ms
71,452 KB
testcase_42 AC 76 ms
75,796 KB
testcase_43 AC 110 ms
77,520 KB
testcase_44 AC 136 ms
77,616 KB
testcase_45 AC 98 ms
77,404 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 color[i][j] == 0:
                    if 0<=i+di<H and 0<=j+dj<W:
                        color[i][j] = 1
                        color[i+di][j+dj] = 1
        if S_num == color:
            #print(di, dj, color)
            ans = 'YES'
print(ans)   
0