I was trying to solve the problem, but couldn’t figure out the solution. It seems some greedy concept is applied by pro coders to solve the problem. It would be good if some one could explain me his/her solution. How we can reduce it to max flow also not able to grab.
This paper explains two solutions to this problem. Both of them can get AC.