This problem is in Contest(s) below:
Contest 1136:负环及差分约束
Contest 1364:环的问题
Contest 1496:YC_最短路
Contest 1218:最短路径
Contest 1318:初二寒假作业及最短路径、最小生成树、并查集
Contest 1355:最靓的仔