hello i’ve tried this problem by DSU approach and i’m getting error while submitting though i got the correct output when compiled and executed with codechef compile
Code link :- https://ide.codingblocks.com/s/358913
hello i’ve tried this problem by DSU approach and i’m getting error while submitting though i got the correct output when compiled and executed with codechef compile
Code link :- https://ide.codingblocks.com/s/358913
Hey @msid78641 run a DFS and make a Union of connected 1’s and give them unique I’d after that check for each zero that if it’s four side has different I’d one’s add the size of different union and store the maximum, this algorithm will run in O(n m) so it will not give tle, your algorithm is taking k n*m time where k is number of zero
See this for reference