Leaves_Flower @ 2017-12-01 16:37:26
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define RG register
#define FT(i, A, B) for(RG int i = A;i <= B;i++)
using namespace std;
const int N = 105;
const int dx[]={-1, 0, 1, 0};
const int dy[]={ 0, 1, 0,-1};
int map[N][N], C, R;
int dist[N][N], ans;
inline void DFS(int x,int y){
int vx, vy;
if(dist[x][y] > ans) ans = dist[x][y];
FT(i,0,3){
vx = x+dx[i];
vy = y+dy[i];
if(vx < 1 || vx > C || vy < 1 || vy > R) continue;
if(map[vx][vy] > map[x][y])
if(!dist[vx][vy] || dist[vx][vy] < dist[x][y] + 1)
dist[vx][vy] = dist[x][y]+1,
DFS(vx,vy);
}
}
int main(){
scanf("%d%d", &C,&R);
FT(i,1,C) FT(j,1,R)
scanf("%d", &map[i][j]);
FT(i,1,C) FT(j,1,R)
if(!dist[i][j])
DFS(i,j);
printf("%d\n", ans+1);
return 0;
}
R.T
by Leaves_Flower @ 2017-12-01 16:38:59
我会告诉你这样写 不卡常数
会被第二个点 1008ms 卡掉的吗
by middle_set @ 2017-12-01 16:49:18
1008是掐断的时间
实际用时还要长
by Leaves_Flower @ 2017-12-01 16:53:31
@hiuseues 我自己测第二个点 ,实际也1s 左右