This problem is in Contest(s) below:
Contest 1492:最小生成树专题
Contest 1413:队列