012 - Red Painting(★4)
union-find で連結成分を管理
赤く塗られたら4方向を見て、隣に赤いマスがあったらUF上で結ぶ
https://atcoder.jp/contests/typical90/submissions/59020892