careercup 4.2: fix a bug that bfs() cannot \
handle loop. (Thanks to zhuzhda!)