Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ans=0;
- int dii[3]={-1,0,1},djj[3]={-1,0,1};
- void fun(char** mat,int i,int j,int m,int n,int curr)
- {
- ans=max(ans,curr);
- for(int x=0;x<3;x++)
- {
- for(int y=0;y<3;y++)
- {
- int di=dii[x],dj=djj[y];
- if(i+di<m && i+di>=0 && j+dj<n && j+dj>=0 && mat[i+di][j+dj]-mat[i][j]=1)
- {
- fun(mat,i+di,j+dj,m,n,curr+1);
- }
- }
- }
- }
- int given(sajdfnajf)
- {
- for(int i=0;i<m;i++)
- {
- for(int j=0;j<n;j++)
- {
- if(mat[i][j]==ch) fun(mat,i,j,m,n,1);
- }
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement