|  | 
|  | 
| back to board | Hint O(n^2) vector<set<int> >
 
 and if WA 5 then test this:
 9
 1 2 3 4 5 6 7 8
 
 and
 
 10
 1 2 3 4 5 6 7 8 9
Re: Hint O(n^2) Hmmmmm....O(n^2) is too slow (-_-).
 I know  O(N+M) solution.You have just to delte leaves, while number of vertex>2.If you will do it righ,you will get O(N+M)solution.
 | 
 | 
|