結果

問題 No.179 塗り分け
ユーザー IJKTanabeIJKTanabe
提出日時 2019-03-21 23:17:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 2,139 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,948 KB
実行使用メモリ 10,324 KB
最終ジャッジ日時 2023-10-19 05:45:54
合計ジャッジ時間 7,203 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,216 KB
testcase_01 AC 30 ms
10,216 KB
testcase_02 WA -
testcase_03 AC 29 ms
10,216 KB
testcase_04 AC 31 ms
10,216 KB
testcase_05 AC 66 ms
10,232 KB
testcase_06 WA -
testcase_07 AC 285 ms
10,276 KB
testcase_08 AC 30 ms
10,264 KB
testcase_09 AC 32 ms
10,276 KB
testcase_10 AC 140 ms
10,324 KB
testcase_11 AC 124 ms
10,312 KB
testcase_12 AC 423 ms
10,324 KB
testcase_13 AC 31 ms
10,216 KB
testcase_14 AC 31 ms
10,224 KB
testcase_15 AC 30 ms
10,216 KB
testcase_16 AC 30 ms
10,216 KB
testcase_17 AC 29 ms
10,216 KB
testcase_18 AC 165 ms
10,304 KB
testcase_19 AC 159 ms
10,292 KB
testcase_20 AC 284 ms
10,292 KB
testcase_21 AC 274 ms
10,276 KB
testcase_22 AC 284 ms
10,276 KB
testcase_23 AC 118 ms
10,280 KB
testcase_24 AC 276 ms
10,276 KB
testcase_25 WA -
testcase_26 AC 134 ms
10,280 KB
testcase_27 AC 275 ms
10,280 KB
testcase_28 AC 151 ms
10,300 KB
testcase_29 AC 283 ms
10,296 KB
testcase_30 AC 111 ms
10,300 KB
testcase_31 AC 292 ms
10,300 KB
testcase_32 AC 134 ms
10,304 KB
testcase_33 AC 302 ms
10,296 KB
testcase_34 AC 143 ms
10,300 KB
testcase_35 AC 309 ms
10,308 KB
testcase_36 AC 30 ms
10,216 KB
testcase_37 AC 30 ms
10,216 KB
testcase_38 AC 30 ms
10,216 KB
testcase_39 AC 30 ms
10,216 KB
testcase_40 AC 31 ms
10,216 KB
testcase_41 AC 31 ms
10,216 KB
testcase_42 AC 31 ms
10,216 KB
testcase_43 AC 44 ms
10,224 KB
testcase_44 AC 72 ms
10,228 KB
testcase_45 AC 33 ms
10,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import time

def main():
    H, W = map(int, input().split())

    cells_list = []
    while len(cells_list) < H:
        cells_list.append(list(input().strip()))
    
    cells_tuple = tuple(tuple(i) for i in cells_list)
    cells_list = None

    black_list = []
    for r in cells_tuple:
        black_list.append([i for i in range(len(r)) if r[i]=='#'])
    
    black_tuple = tuple(tuple(i) for i in black_list)
    black_list = None

    start_time = time.time()

    for y in range((-H)+1, H):
        for x in range((-W)+1, W):
            if try_paint(cells_tuple, black_tuple, H, W, y, x) == True:
                print('YES')
                #print(format(time.time() - start_time))
                exit(0)
    
    print('NO')
    #print(format(time.time() - start_time))


def try_paint(cells_tuple, black_tuple, H, W, vecY, vecX):

    _cells = list(list(i) for i in cells_tuple)
    _black_list = list(list(i) for i in black_tuple)

    flg = None

    rangeY = list(range(0,H))
    #rangeX = list(range(0,W))
    
    if vecY < 0:
        rangeY.reverse()

    # pos関数はインデックス指定だと時間がかかるという事で
    if vecX < 0:
        #rangeX.reverse()
        for i in _black_list:
            i.reverse()

    for y in rangeY:
        while len(_black_list[y]) != 0:

            x = _black_list[y].pop()

            # 赤色に塗る
            #_cells[y][x] = 'R'
        
            #Todo 青色に塗る判定
            trgY = y + vecY
            trgX = x + vecX
            if trgY in rangeY and trgX in _black_list[trgY]:
                #_cells[trgY][trgX] = 'B'
                _black_list[trgY].remove(trgX)
                if flg == None: flg = True
            else:
                # flg = False
                return False

    # if flg == True:  
    #     print('')
    #     print('vec = ' + str(vecY) + ', ' + str(vecX))
    #     for r in _cells:
    #         print(''.join(r))
    #     print(flg)
    #     input()

    return flg

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