Matrix Search Problem

https://ide.codingblocks.com/s/465096

Please have a look at this solution. Giving Time limit exceeded warning & compilation error. Do suggest the changes.