結果

問題 No.179 塗り分け
ユーザー MitI_7MitI_7
提出日時 2015-12-27 14:13:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 821 ms / 3,000 ms
コード長 1,132 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 8,404 KB
最終ジャッジ日時 2023-09-30 20:45:43
合計ジャッジ時間 6,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,912 KB
testcase_01 AC 18 ms
7,760 KB
testcase_02 AC 18 ms
7,812 KB
testcase_03 AC 26 ms
7,720 KB
testcase_04 AC 17 ms
7,828 KB
testcase_05 AC 17 ms
7,788 KB
testcase_06 AC 16 ms
7,840 KB
testcase_07 AC 821 ms
8,236 KB
testcase_08 AC 293 ms
8,308 KB
testcase_09 AC 300 ms
8,336 KB
testcase_10 AC 17 ms
8,280 KB
testcase_11 AC 17 ms
8,232 KB
testcase_12 AC 297 ms
8,348 KB
testcase_13 AC 31 ms
7,792 KB
testcase_14 AC 85 ms
7,948 KB
testcase_15 AC 16 ms
7,912 KB
testcase_16 AC 16 ms
7,860 KB
testcase_17 AC 21 ms
7,828 KB
testcase_18 AC 22 ms
8,224 KB
testcase_19 AC 22 ms
8,404 KB
testcase_20 AC 17 ms
8,292 KB
testcase_21 AC 17 ms
7,964 KB
testcase_22 AC 513 ms
8,216 KB
testcase_23 AC 17 ms
8,380 KB
testcase_24 AC 310 ms
8,228 KB
testcase_25 AC 18 ms
8,196 KB
testcase_26 AC 55 ms
8,332 KB
testcase_27 AC 292 ms
8,196 KB
testcase_28 AC 27 ms
8,272 KB
testcase_29 AC 288 ms
8,280 KB
testcase_30 AC 127 ms
8,380 KB
testcase_31 AC 289 ms
8,184 KB
testcase_32 AC 89 ms
8,336 KB
testcase_33 AC 294 ms
8,324 KB
testcase_34 AC 67 ms
8,192 KB
testcase_35 AC 288 ms
8,360 KB
testcase_36 AC 35 ms
7,888 KB
testcase_37 AC 17 ms
7,796 KB
testcase_38 AC 26 ms
7,916 KB
testcase_39 AC 23 ms
7,948 KB
testcase_40 AC 25 ms
7,872 KB
testcase_41 AC 16 ms
7,876 KB
testcase_42 AC 24 ms
7,756 KB
testcase_43 AC 84 ms
7,916 KB
testcase_44 AC 126 ms
7,788 KB
testcase_45 AC 39 ms
7,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(d, r, field):
    find = False
    for y in range(len(field)):
        ny = y + d
        if not (0 <= ny < len(field)):
            continue
        for x in range(len(field[y])):
            if field[y][x] == '#':
                nx = x + r
                if 0 <= nx < len(field[y]) and field[ny][nx] == '#':
                    find = True
                    field[y][x] = 0
                    field[ny][nx] = 1
                else:
                    return False

    for line in field:
        if '#' in line:
            return False

    return find


def main():
    h, w = map(int, input().split())
    field = []
    num_of_sharps = 0
    for _ in range(h):
        line = list(input())
        field.append(line)
        num_of_sharps += line.count('#')

    if num_of_sharps % 2 != 0:
        print("NO")
        return

    for i in range(50):
        for j in range(-50, 50):
            if i == 0 and j <= 0:
                continue

            if func(i, j, [[i for i in j] for j in field]):
                print("YES")
                return
    print("NO")

if __name__ == '__main__':
    main()
0