Here is the problem: http://www.spoj.com/problems/ABCD/ Can anyone rectify my code? I am getting an NZEC however I have tried all the testcases(available along with the problem and a few mentioned in the comments) with correct outputs. If my code looks extremely complicated and confusing,well I'm sorry for that.
Here is my work: http://ideone.com/2Wvax7
Thank you.