a hard sol:DFS,tree.How to calculate complexity.