here is the link to my solution:

https://www.codechef.com/viewsolution/37549925

need help to find where am I wrong,

My logic is:

if n<3 no swap possible

next we know that it is possible only when n is of form 4k+3 of 4k

in that case i calculated “i” such that the sum 1+2+3+…+i is just greater than half of sum 1+2+3…+n (which is k)

and if sum of first i terms is equal to last n-i terms we may do any swap(between first i numbers or between least n-i numbers so for that cases will be iC2* (n-i)C2 (however later i realised that it is possible only when n=3),

and if sums aren’t equal it can do (n-i) swap.

Thanks