結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2015-10-21 17:15:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 671 ms / 3,000 ms |
コード長 | 911 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-23 14:33:05 |
合計ジャッジ時間 | 4,186 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
import copy H, W = map(int, input().split()) S = [] for i in range(H): S.append([c for c in input()]) cnt_black = sum(S[i].count('#') for i in range(H)) if cnt_black % 2 == 1 or cnt_black == 0: print('NO') exit() for h in range(H): for w in range(-W + 1, W): if h == 0 and w <= 0: continue s = [row[:] for row in S] cnt = 0 flg = False for i in range(H): for j in range(W): if s[i][j] == '#': if 0 <= i + h < H and 0 <= j + w < W and s[i + h][j + w] == '#': s[i][j] = 'r' s[i + h][j + w] = 'b' cnt += 2 else: flg = True break if flg: break if cnt == cnt_black: print('YES') exit() print('NO')