Thanks for the information shared on this thread! Otherwise, it would have been difficult to guess where my program went wrong.

To contribute my 2 cents, I considered the following and got accepted:

1) A region may not necessarily contain n pairs of coordinates (it can be 0 as well

).

2) If a region size is less than n, consider the output as wrong.

3) If a region is discovered more than once, consider the output as wrong.

4) The total number of *distinct* regions should be equal to n.

5) I assumed that all values are in the range [1..n].

Hope the above points will help you in solving this problem.

Cheers!