farhin_khaled

Flood Fill

Oct 24th, 2021
739
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void BT(int r, int c){
  2.     if(grid[r][c] == '#'){
  3.         cout << "win" << endl;
  4.         return;
  5.     }
  6.  
  7.     if(valid(r, c+1)) BT(r, c+1);
  8.  
  9.     if(valid(r, c-1)) BT(r, c-1);
  10.  
  11.     if(valid(r+1, c)) BT(r+1, c);
  12.  
  13.     if(valid(r-1, c)) BT(r-1, c);
  14. }
RAW Paste Data