A question regarding Bitmask DP.

Question–>http://community.topcoder.com/stat?c=problem_statement&pm=11788&rd=14726

Below is my solution uses bitmask DP logic. However, having spent close to three days, my code is still yielding 0 to each and every test-case, which is simply driving me mad. Any help will be much appreciated.

CODE --> http://ideone.com/dF27C3