I was trying to solve this problem in Egyptian ECPC but I couldn't. Can anyone give me a hint ?
someone who already solved it said that he use disjoint set but I couldn't handle it using disjoint set .

I was trying to solve this problem in Egyptian ECPC but I couldn't. Can anyone give me a hint ?
someone who already solved it said that he use disjoint set but I couldn't handle it using disjoint set .
