結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2019-03-21 21:09:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 442 ms / 3,000 ms |
コード長 | 2,057 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-23 14:56:30 |
合計ジャッジ時間 | 7,320 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
import sys 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 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') exit(0) print('NO') 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() if vecX < 0: #rangeX.reverse() for i in _black_list: i.reverse() for y in rangeY: for x in _black_list[y]: # 赤色に塗る判定 if _cells[y][x] == '#': _cells[y][x] = 'R' #Todo 青色に塗る判定 trgY = y + vecY trgX = x + vecX if trgY in range(0,H) and trgX in range(0,W): if _cells[trgY][trgX] == '#': _cells[trgY][trgX] = 'B' if flg == None: flg = True else: # flg = False return False 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()