Here is my code for the problem. The code is running fine on my Code::blocks but not on spoj site and on ideone.com.I get a runtime error. I guess the spoj server cannot allocate the required amount of memory. Please give some suggestions.
http://paste.ubuntu.com/1277109/ ( MY code )
Your code is declaring an empty string
sand then is assigning to elements of it…