SIGSEGV error

can anyone tell me why the program at this link:http://www.codechef.com/viewsolution/2366766
is showing SIGSEGV error.

DON’T use malloc. You are using C++, so why not just use std::vector? No memory management troubles.

Moreover all your members (of class) are public, so instead use a struct.

//