Painter Problem

Can anyone help me in this code please !!
I’m not able to pass even a single test case .

LINK TO MY CODE : https://ide.codingblocks.com/s/276439