Needed Help in TWOFL problem ? Getting WA answer except 3 test Cases.. plz plz

My Approach is same As mentioned in editorial :-

  1. create component for same type
  2. create edges for different component
  3. use union find (dsu) concept

I am not able to find out any Test case where my code is giving WA answer… plz someOne provide any test case for my code is not giving right answer

solution link:- link


Output ScreenShot:-alt text

4 5

1 2 1 2 1

2 1 2 1 2

1 2 1 2 1

2 1 2 1 2

Your code gives 49 whereas ans is 20.

1 Like

thanks Bro