Any better solutions?
I use DFS to solve this problem, and my program ran for a pretty long time.
Here is my program(C++).
#ifndef ONLINE_JUDGE
#define ONLINE_JUDGE
#endif
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
#ifndef ONLINE_JUDGE
#include <stdio.h>
#endif
#define MAX_TREE ...