TLE using bitmasks.... :(

Why does using a O(2^N * N) approach for this question give TLE…
Solution :- http://www.codechef.com/viewsolution/3652333

//