結果

問題 No.179 塗り分け
ユーザー lloyzlloyz
提出日時 2023-05-25 00:07:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 227 ms / 3,000 ms
コード長 1,325 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 78,156 KB
最終ジャッジ日時 2023-08-25 14:59:31
合計ジャッジ時間 7,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,304 KB
testcase_01 AC 74 ms
71,572 KB
testcase_02 AC 71 ms
71,464 KB
testcase_03 AC 73 ms
71,352 KB
testcase_04 AC 73 ms
71,452 KB
testcase_05 AC 72 ms
71,264 KB
testcase_06 AC 76 ms
75,248 KB
testcase_07 AC 74 ms
75,452 KB
testcase_08 AC 178 ms
77,848 KB
testcase_09 AC 178 ms
77,728 KB
testcase_10 AC 85 ms
76,756 KB
testcase_11 AC 88 ms
76,440 KB
testcase_12 AC 179 ms
77,792 KB
testcase_13 AC 75 ms
75,000 KB
testcase_14 AC 78 ms
76,164 KB
testcase_15 AC 70 ms
71,344 KB
testcase_16 AC 73 ms
71,300 KB
testcase_17 AC 71 ms
71,300 KB
testcase_18 AC 99 ms
77,404 KB
testcase_19 AC 102 ms
77,336 KB
testcase_20 AC 77 ms
75,680 KB
testcase_21 AC 76 ms
75,632 KB
testcase_22 AC 227 ms
78,156 KB
testcase_23 AC 90 ms
76,616 KB
testcase_24 AC 184 ms
78,008 KB
testcase_25 AC 85 ms
76,376 KB
testcase_26 AC 111 ms
77,176 KB
testcase_27 AC 183 ms
77,632 KB
testcase_28 AC 101 ms
77,484 KB
testcase_29 AC 187 ms
78,060 KB
testcase_30 AC 146 ms
77,580 KB
testcase_31 AC 177 ms
77,764 KB
testcase_32 AC 133 ms
77,524 KB
testcase_33 AC 190 ms
77,624 KB
testcase_34 AC 117 ms
77,552 KB
testcase_35 AC 195 ms
78,072 KB
testcase_36 AC 76 ms
71,452 KB
testcase_37 AC 71 ms
71,464 KB
testcase_38 AC 72 ms
71,152 KB
testcase_39 AC 72 ms
71,528 KB
testcase_40 AC 74 ms
75,036 KB
testcase_41 AC 71 ms
71,384 KB
testcase_42 AC 74 ms
75,020 KB
testcase_43 AC 88 ms
76,712 KB
testcase_44 AC 110 ms
77,192 KB
testcase_45 AC 80 ms
76,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

c = 0
for i in range(h):
    for j in range(w):
        if F[i][j] == '#':
            c += 1
if c == 0 or c % 2 == 1:
    print("NO")
    exit()

for di in range(h):
    for dj in range(-w + 1, w):
        if di == 0 and dj == 0:
            continue
        C = [[None for _ in range(w)] for _ in range(h)]
        flag = True
        for i in range(h):
            for j in range(w):
                if F[i][j] == '#' and C[i][j] == None:
                    C[i][j] = 'R'
                    if 0 <= i + di < h and 0 <= j + dj < w:
                        if F[i + di][j + dj] == '#' and C[i + di][j + dj] == None:
                            C[i + di][j + dj] = 'B'
                        else:
                            flag = False
                            break
                    else:
                        flag = False
                        break
            if not flag:
                break
        if flag:
            for i in range(h):
                for j in range(w):
                    if F[i][j] == '#' and C[i][j] == None:
                        flag = False
                        break
                if not flag:
                    break
        if flag:
            print("YES")
            exit()
print("NO")
0