Colouring the grid codechef

link to problem :- https://www.codechef.com/problems/CLORGIRD
my solution:- https://ide.codingblocks.com/s/37570
i tried checking if i can find a ‘.’ in between 2 ‘#’ for this i just added ‘#’ all around my grid so if anywhere in my initial grid i find ‘#’ i will search if i m having a ‘.’ adjacent to it in all the directions and a ‘#’ at position adjacent to the ‘.’ if i find any such case i will return NO. and if i dont find any such case its YES. its almost same as sachit777’s soution which you have replied but i am checking the top and bottom as well and the case which you give him is working with my algo but last case is giving WA while submitting. what could be the issue?

Instead of checking just the immediate neighbours(when you find a ‘#’), shouldn’t you be checking all the neighbours?