Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- int row,col,run,arr[105][105];
- void longestrun(int i,int j,int x,int pre)
- {
- if(arr[i][j]>=pre || i==0 || j==0 || i>row || j>col )
- {
- run=max(run,x);
- return;
- }
- longestrun(i,j+1,x+1,arr[i][j]);
- longestrun(i,j-1,x+1,arr[i][j]);
- longestrun(i+1,j,x+1,arr[i][j]);
- longestrun(i-1,j,x+1,arr[i][j]);
- }
- int main()
- {
- string s;
- int t,cas,i,j,k,n,m;
- cin>>t;
- while(t--)
- {
- cin>>s>>row>>col;
- cout<<s<<": ";
- for(i=1; i<=row; i++)
- {
- for(j=1; j<=col; j++)
- {
- cin>>arr[i][j];
- }
- }
- run=0;
- for(i=1; i<=row; i++)
- {
- for(j=1; j<=col; j++)
- {
- longestrun(i,j+1,1,arr[i][j]);
- longestrun(i,j-1,1,arr[i][j]);
- longestrun(i+1,j,1,arr[i][j]);
- longestrun(i-1,j,1,arr[i][j]);
- }
- }
- cout<<run<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement