結果

問題 No.179 塗り分け
ユーザー IJKTanabeIJKTanabe
提出日時 2019-03-20 20:51:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,904 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 79,416 KB
最終ジャッジ日時 2023-10-19 04:34:00
合計ジャッジ時間 22,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,400 KB
testcase_01 AC 41 ms
53,400 KB
testcase_02 AC 50 ms
61,816 KB
testcase_03 WA -
testcase_04 AC 59 ms
66,032 KB
testcase_05 WA -
testcase_06 AC 158 ms
76,428 KB
testcase_07 AC 637 ms
78,336 KB
testcase_08 AC 650 ms
78,528 KB
testcase_09 AC 645 ms
78,372 KB
testcase_10 AC 875 ms
78,868 KB
testcase_11 AC 748 ms
78,396 KB
testcase_12 WA -
testcase_13 AC 56 ms
66,080 KB
testcase_14 AC 57 ms
66,204 KB
testcase_15 AC 40 ms
53,404 KB
testcase_16 AC 39 ms
53,404 KB
testcase_17 AC 40 ms
53,404 KB
testcase_18 AC 830 ms
79,024 KB
testcase_19 AC 744 ms
78,848 KB
testcase_20 AC 759 ms
79,044 KB
testcase_21 AC 697 ms
78,636 KB
testcase_22 AC 689 ms
78,668 KB
testcase_23 AC 762 ms
78,836 KB
testcase_24 AC 677 ms
78,516 KB
testcase_25 AC 680 ms
78,416 KB
testcase_26 AC 783 ms
78,812 KB
testcase_27 WA -
testcase_28 AC 891 ms
78,812 KB
testcase_29 WA -
testcase_30 AC 914 ms
78,792 KB
testcase_31 WA -
testcase_32 AC 904 ms
79,064 KB
testcase_33 WA -
testcase_34 AC 942 ms
79,240 KB
testcase_35 WA -
testcase_36 AC 40 ms
53,404 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 42 ms
53,404 KB
testcase_40 AC 57 ms
63,996 KB
testcase_41 AC 40 ms
53,404 KB
testcase_42 AC 50 ms
61,084 KB
testcase_43 AC 142 ms
76,240 KB
testcase_44 AC 234 ms
77,008 KB
testcase_45 AC 113 ms
75,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    try:
        #H, W = map(int, input('行数 列数 = ? ').split())
        H, W = map(int, input().split())
    except:
        print('入力に誤りがあります。終了します')
        sys.exit(0)

    cells = []
    while len(cells) < H:
        #_input = input(str(len(cells) + 1) + ': = ? ')
        _input = input()

        if (len(_input) == W) and (len(_input.replace('#', '').replace('.', '')) == 0):
            cells.append(list(_input.strip()))
        else:
            print('')
            if len(_input) != W:
                print('*** ' + str(W) + '文字で入力してください' + ' ***')
            if len(_input.replace('#', '').replace('.', '')) != 0:
                print('*** \'#\'と\'.\'のみで入力してください ***')
            print('')
    
    cells_tuple = tuple(tuple(i) for i in cells)
    cells = None

    result = []
    for y in range((-H)+1, H):
        for x in range((-W)+1, W):
            result.append(try_paint(cells_tuple, H, W, y, x))
    
    #print(result)
    if True in result:
        print('YES')
    else:
        print('NO')



def try_paint(cells, H, W, vecY, vecX):

    _cells = list(list(i) for i in cells)

    #input('vectorY = ' + str(vecY) + ' : vectorX = ' + str(vecX))
    flg = None

    if vecY < 0:
        rangeY = reversed(range(0,H))
    else:
        rangeY = range(0,H)
    
    if vecX < 0:
        rangeX = reversed(range(0,W))
    else:
        rangeX = range(0,W)


    for y in rangeY:
        for x in rangeX:
            
            refY = y - vecY
            refX = x - vecX
            trgY = y + vecY
            trgX = x + vecX
            
            #print ('y = ' + str(y) + ': x = ' + str(x) + 'is now \'' + _cells[y][x] + '\'' )

            # 赤色に塗る判定
            if _cells[y][x] == '#':
                if refY in range(0,H) and refX in range(0,W):
                    if _cells[refY][refX] != '#':
                        _cells[y][x] = 'R'
                else: _cells[y][x] = 'R'
            
            #Todo 青色判定も、マイナスインデックスの影響排除
            if _cells[y][x] == 'R':
                if trgY in range(0,H) and trgX in range(0,W):
                    if _cells[trgY][trgX] == '#':
                        _cells[trgY][trgX] = 'B'
                        #print('paint to RED and BLUE')
                        if flg == None: flg = True
                    else:
                        #print('paint to RED but BLUE !!!!!')
                        flg = False
                else:
                    #print('paint to RED but BLUE !!!!!')
                    flg = False

    # for line in _cells:
    #     print(''.join(line))
    # print(flg)
    return flg

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