結果

問題 No.179 塗り分け
ユーザー roiti46roiti46
提出日時 2015-04-06 01:09:06
言語 PyPy2
(7.3.13)
結果
AC  
実行時間 348 ms / 3,000 ms
コード長 848 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 77,672 KB
実行使用メモリ 80,560 KB
最終ジャッジ日時 2023-09-30 20:38:01
合計ジャッジ時間 10,232 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
76,436 KB
testcase_01 AC 76 ms
76,176 KB
testcase_02 AC 78 ms
76,340 KB
testcase_03 AC 77 ms
76,340 KB
testcase_04 AC 88 ms
79,212 KB
testcase_05 AC 77 ms
76,180 KB
testcase_06 AC 87 ms
79,184 KB
testcase_07 AC 80 ms
77,276 KB
testcase_08 AC 231 ms
79,468 KB
testcase_09 AC 225 ms
79,648 KB
testcase_10 AC 95 ms
79,412 KB
testcase_11 AC 95 ms
79,356 KB
testcase_12 AC 228 ms
79,756 KB
testcase_13 AC 86 ms
78,352 KB
testcase_14 AC 85 ms
79,020 KB
testcase_15 AC 79 ms
76,264 KB
testcase_16 AC 77 ms
76,716 KB
testcase_17 AC 77 ms
76,504 KB
testcase_18 AC 109 ms
79,396 KB
testcase_19 AC 107 ms
79,236 KB
testcase_20 AC 83 ms
78,636 KB
testcase_21 AC 78 ms
77,248 KB
testcase_22 AC 348 ms
80,560 KB
testcase_23 AC 99 ms
79,368 KB
testcase_24 AC 253 ms
80,164 KB
testcase_25 AC 94 ms
79,476 KB
testcase_26 AC 133 ms
79,624 KB
testcase_27 AC 282 ms
79,760 KB
testcase_28 AC 117 ms
79,820 KB
testcase_29 AC 315 ms
79,788 KB
testcase_30 AC 196 ms
79,696 KB
testcase_31 AC 337 ms
79,868 KB
testcase_32 AC 161 ms
79,548 KB
testcase_33 AC 294 ms
79,900 KB
testcase_34 AC 150 ms
79,536 KB
testcase_35 AC 301 ms
79,692 KB
testcase_36 AC 78 ms
76,388 KB
testcase_37 AC 77 ms
76,292 KB
testcase_38 AC 76 ms
76,496 KB
testcase_39 AC 76 ms
76,428 KB
testcase_40 AC 84 ms
78,908 KB
testcase_41 AC 76 ms
76,428 KB
testcase_42 AC 82 ms
78,492 KB
testcase_43 AC 97 ms
79,008 KB
testcase_44 AC 123 ms
79,608 KB
testcase_45 AC 95 ms
78,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, raw_input().split())
S = [list(raw_input()) for i in xrange(H)]

black = 0
for y in xrange(H):
    for x in xrange(W):
        if S[y][x] == "#": black += 1
if black == 0 or black % 2 == 1:
    print "NO"
    exit()
    
for dy in xrange(H):
    for dx in xrange(-W, W):
        if abs(dx) + dy == 0: continue

        flag = True
        used = [[S[y][x] == "." for x in xrange(W)] for y in xrange(H)] 

        for y in xrange(H-dy):
            for x in xrange(W):
                if used[y][x]: continue
                if not (0 <= x+dx < W) or used[y+dy][x+dx]:
                    flag = False
                    break
                used[y][x] = used[y+dy][x+dx] = True
            if not flag: break
        else:
            if sum(map(sum, used)) != H*W: continue
            print "YES"
            exit()

print "NO"
0