This problem is in Contest(s) below:
Contest 1338:图的连通性
Contest 1433:图的连通性
Contest 1505:图的连通块
Contest 1504:YC_2021_4月
Contest 1355:最靓的仔