結果

問題 No.179 塗り分け
ユーザー pajannatpajannat
提出日時 2021-04-13 23:25:47
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 2,240 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 88,032 KB
最終ジャッジ日時 2023-09-12 13:57:50
合計ジャッジ時間 35,205 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,852 KB
testcase_01 AC 90 ms
71,480 KB
testcase_02 AC 114 ms
77,420 KB
testcase_03 AC 89 ms
71,860 KB
testcase_04 AC 112 ms
77,080 KB
testcase_05 AC 250 ms
78,408 KB
testcase_06 AC 191 ms
78,516 KB
testcase_07 WA -
testcase_08 AC 1,075 ms
87,108 KB
testcase_09 AC 1,079 ms
87,068 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,171 ms
86,008 KB
testcase_13 AC 105 ms
77,400 KB
testcase_14 AC 105 ms
77,572 KB
testcase_15 AC 87 ms
71,744 KB
testcase_16 AC 87 ms
71,640 KB
testcase_17 AC 86 ms
71,652 KB
testcase_18 AC 1,324 ms
87,592 KB
testcase_19 WA -
testcase_20 AC 1,221 ms
87,176 KB
testcase_21 AC 1,102 ms
87,424 KB
testcase_22 AC 1,289 ms
87,500 KB
testcase_23 WA -
testcase_24 AC 1,089 ms
87,328 KB
testcase_25 AC 1,094 ms
87,224 KB
testcase_26 AC 1,109 ms
87,236 KB
testcase_27 AC 1,180 ms
87,248 KB
testcase_28 AC 1,292 ms
87,436 KB
testcase_29 AC 1,402 ms
88,032 KB
testcase_30 AC 1,371 ms
87,544 KB
testcase_31 AC 1,282 ms
87,520 KB
testcase_32 AC 1,358 ms
87,496 KB
testcase_33 AC 1,322 ms
87,524 KB
testcase_34 AC 1,388 ms
87,592 KB
testcase_35 AC 1,298 ms
87,752 KB
testcase_36 AC 86 ms
71,632 KB
testcase_37 AC 86 ms
71,688 KB
testcase_38 AC 85 ms
71,460 KB
testcase_39 AC 85 ms
71,544 KB
testcase_40 AC 94 ms
76,396 KB
testcase_41 AC 86 ms
71,624 KB
testcase_42 AC 86 ms
71,632 KB
testcase_43 AC 155 ms
78,176 KB
testcase_44 AC 262 ms
78,440 KB
testcase_45 AC 127 ms
77,976 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なしなら"YES"を出力
                if flg:
                    print("YES")
                    success_flg = True                   
                        
    # 一度も"YES"を出力していない場合、"NO"を出力
    if success_flg==False:
        print("NO")

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