結果

問題 No.179 塗り分け
ユーザー pajannatpajannat
提出日時 2021-04-13 23:49:31
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 2,217 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 88,296 KB
最終ジャッジ日時 2023-09-12 14:40:31
合計ジャッジ時間 36,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 86 ms
71,688 KB
testcase_02 WA -
testcase_03 AC 87 ms
71,820 KB
testcase_04 WA -
testcase_05 AC 251 ms
78,708 KB
testcase_06 WA -
testcase_07 AC 1,056 ms
87,220 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,157 ms
86,124 KB
testcase_13 AC 105 ms
77,468 KB
testcase_14 AC 104 ms
77,460 KB
testcase_15 AC 87 ms
71,448 KB
testcase_16 WA -
testcase_17 AC 86 ms
71,552 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,237 ms
87,172 KB
testcase_21 AC 1,103 ms
87,352 KB
testcase_22 AC 1,285 ms
87,440 KB
testcase_23 WA -
testcase_24 AC 1,082 ms
87,240 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1,236 ms
87,332 KB
testcase_28 WA -
testcase_29 AC 1,395 ms
88,296 KB
testcase_30 WA -
testcase_31 AC 1,275 ms
87,488 KB
testcase_32 WA -
testcase_33 AC 1,281 ms
87,492 KB
testcase_34 WA -
testcase_35 AC 1,339 ms
87,416 KB
testcase_36 AC 87 ms
71,764 KB
testcase_37 AC 89 ms
71,744 KB
testcase_38 AC 87 ms
71,676 KB
testcase_39 AC 85 ms
71,668 KB
testcase_40 AC 94 ms
76,316 KB
testcase_41 AC 85 ms
71,608 KB
testcase_42 AC 86 ms
71,576 KB
testcase_43 AC 154 ms
78,004 KB
testcase_44 AC 259 ms
78,424 KB
testcase_45 AC 125 ms
77,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    # 入力行数が多いとき。
    from sys import stdin
    # 数値として入力一つを読み込み
    H, W = map(int, stdin.readline().rstrip().split())
    d = [stdin.readline().rstrip() for i in range(H)]

    # 平行移動が成功したかどうかを判断するフラグ
    success_flg = False
    blue = [[False for w in range(W)] for h in range(H)]
    # リストblueの値を渡す
    import copy
    blue_tmp = copy.deepcopy(blue)

    # 平行移動パターンの全探索
    for i in range(H):
        for j in range(-W+1,W):
            # 移動なしパターンを除外
            if i == 0 and j == 0:
                pass
            # 左方向への移動を除外
            elif i == 0 and j < 0:
                pass
            else:
                # すべてのマスを平行移動する
                # 最後までflg=TrueならYESを出力
                flg = True
                # マスの色を初期化
                blue_tmp = copy.deepcopy(blue)
                for h in range(H):
                    for w in range(W):
                        # マスが白色または青色の場合は判定しない
                        if d[h][w] == "." or blue_tmp[h][w]:
                            pass
                        # 平行移動して範囲内の場合に判定
                        elif h+i<H and h+i>=0 and w+j<W and w+j>=0:
                            if d[h][w] == "#" and d[h+i][w+j] == "#":
                                blue_tmp[h+i][w+j] = True
                            # 平行移動先のマスが"#"でない場合はNG
                            else:
                                flg = False
                        # 平行移動して範囲外に出る場合はNG
                        else:
                            flg = False
                # すべてのマスを平行移動させて最後までNGなし
                # 1マス以上青マスがある
                if flg and (True in blue_tmp):
                    success_flg = True                   
                        
    if success_flg:
        print("YES")
    else:
        print("NO")

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