Advertisement
at3107

Untitled

Nov 26th, 2020
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. int ans=0;
  2. int dii[3]={-1,0,1},djj[3]={-1,0,1};
  3.  
  4. void fun(char** mat,int i,int j,int m,int n,int curr)
  5. {
  6.     ans=max(ans,curr);
  7.     for(int x=0;x<3;x++)
  8.     {
  9.         for(int y=0;y<3;y++)
  10.         {
  11.             int di=dii[x],dj=djj[y];
  12.             if(i+di<m && i+di>=0 && j+dj<n && j+dj>=0 && mat[i+di][j+dj]-mat[i][j]=1)
  13.             {
  14.                 fun(mat,i+di,j+dj,m,n,curr+1);
  15.             }
  16.         }
  17.     }
  18. }
  19.  
  20. int given(sajdfnajf)
  21. {
  22.     for(int i=0;i<m;i++)
  23.     {
  24.         for(int j=0;j<n;j++)
  25.         {
  26.             if(mat[i][j]==ch) fun(mat,i,j,m,n,1);
  27.         }
  28.     }
  29.     return ans;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement