/*滑雪Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 65925 Accepted: 24174DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。Input输入的第一行表示区域的行数R和列数C(1 <= R,C <= 100)。下面是R行,每行有C个整数,代表高度h,0<=h<=10000。Output输出最长区域的长度。Sample Input5 51 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9Sample Output25SourceSHTSC 2002*/#includeusing namespace std;int a[105][105] = {0}, ans[105][105] = {0}, r = 0, c = 0, max1 = 0;void dfs(int x, int y){ int dx[5] = {0, 0, 1, -1}, dy[5] = {1, -1, 0, 0}, i = 0; if(ans[x][y]) return; for(ans[x][y] = 1, i = 0; i < 4; i++) if(x + dx[i] >= 0 && x + dx[i] < r && y + dy[i] >= 0 && y + dy[i] < c && a[x][y] > a[x + dx[i]][y + dy[i]]) { dfs(x + dx[i], y + dy[i]); if(ans[x + dx[i]][y + dy[i]] + 1 > ans[x][y]) ans[x][y] = ans[x + dx[i]][y + dy[i]] + 1; } if(max1 < ans[x][y]) max1 = ans[x][y];}int main(){ int i = 0, j = 0; cin >> r >> c; for( i = 0; i < r; i++) for( j = 0; j < c; j++) cin >> a[i][j]; for(max1 = 0, i = 0; i < r; i++) for(j = 0; j < c; j++) dfs(i, j); cout << max1;}