p1011

use bool array instead of unsigned long to track visited node