[1] gives `impossible` while it's `possible`. It's the mistake in your logic you need to correct. If you'll go by your code and see how it's working when `li=ri`, it then becomes simple to get the case. I'd like to mention here that for getting the test cases to test, always explore the possibilities and then see how your code should work for that manually and then check your output and the one your code is giving.
[1]: http://ideone.com/2rUVJc

I would like to tell you that you have understood the problem the problem … wrongly … dear…

Problem says that you can shuffle all the elements in the range from L to R… and you have done it for where we can swap element L and R … Here is my AC solution for this problem …

I am posting a test case for which your solution will give wrong result …

Oh, I missed that point. But I tested my code for this case and it gave “possible”. I’ll see to it once again, but then there’s surely some test case in test file then according to the constraints.

Hey first of let me tell you what is he doing in his code… if you have checked then he is just making an edge between the pair of integers and then just finding the connected components right …

let us consider … we have five elements in the arrays names as

A B C D E respectively …

2 segments …

A->B
B->D

what does that mean according to his code …

A,B,D are connected and he can change position of these elements to obtain the given permutation right …

I solved this problem during the contest itself and also my code is bit clear you can understand it …

I am just merging the segment which can be possibly merge and checking whether i have all the element in the merged range which i need to make the required permutation …

Yeah, thanks. I just missed that part of the code, Even I solved during the contest by merging the intervals and then did the same check as in your code. Thanks for the help…