How to solve HDU 1312 Red and Black problem using DFS algorithm?