this is the contest http://mirror.codeforces.com/contest/719 question no 2 can anyone tell me why i m failing 5th test case because i cant see that due to its large input plz help me guys thnxx.... hhttp://mirror.codeforces.com/contest/719/submission/20852280
In the problem statement they say that you can swap any two cockroaches not only adjacent ones, this error must appear starting from the 4th test but since your second loop only deal with first n-1 cockroaches it made no errors in that test .