Aliens "http://www.codechef.com/problems/DOWNLOAD "

How to crack this problem? Can anyone help me with Logic and the code?

I guess the editorial would work :