Advertisement
rotti321

fill

Jun 2nd, 2021
758
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. const int N=405;
  7.  
  8. int n, m, nrzones;
  9. char a[N][N],cu;
  10. int  b[N][N], dx[]={-1, 0, 1, 0}, dy[]={0, 1, 0, -1}, d[N*N],p;
  11. bool c[N*N];
  12.  
  13. void filll(int x, int y)
  14. {
  15.     b[x][y]=nrzones;
  16.     d[nrzones]++;
  17.     for(int i=0;i<4;i++)
  18.     {
  19.         if( !b[x+dx[i]][y+dy[i]] && a[x][y]==a[x+dx[i]][y+dy[i]] )
  20.             filll(x+dx[i], y+dy[i]);
  21.     }
  22. }
Advertisement
RAW Paste Data Copied
Advertisement