SHARE
TWEET

Untitled

a guest Oct 21st, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. ifstream f("bila.in");
  8. ofstream g("bila.out");
  9.  
  10. int a[101][101],n,m,x,y,i1,j1,i2,j2,s,b[101][101];
  11. int d[4]= {-1,0,1,0}, dc[4]= {0,1,0,-1};
  12.  
  13. void afisare(int k)
  14. {
  15.     if(k>s)
  16.         s=k;
  17. }
  18.  
  19. void bkt(int k, int l, int c)
  20. {
  21.     for(int i=0; i<4; i++)
  22.     {
  23.         int x=l+d[i], y=c+dc[i];
  24.         if(x>0 && x<=n && y>0 && y<=m && a[l][c]>a[x][y] && b[x][y]==0)
  25.         {
  26.             b[x][y]=k;
  27.             if(x==1 or x==n or y==1 or y==m)
  28.                 afisare(k);
  29.             else
  30.                 bkt(k+1,x,y);
  31.         b[x][y]=0;
  32.         }
  33.     }
  34. }
  35.  
  36. int main()
  37. {
  38.     f>>n>>m;
  39.  
  40.     for(int i=1;i<=n;i++)
  41.         for(int j=1;j<=m;j++)
  42.             f>>a[i][j];
  43.    f>>x>>y;
  44.    b[x][y]=1;
  45.    bkt(2,x,y);
  46.    g<<s;
  47.  
  48.     return 0;
  49.  
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top