分类: C/C++
2010-09-09 09:51:22
#include#define N 102 int g[N][N]; int ans[N][N]; int mov[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1}; int max; int c, r; int in(int x, int y) { if(x<0 || x>=c || y<0 || y>=r) return 0; return 1; } //pre为0,标志为起始点 void dfs(int k, int pre) { int i, t; int tx, ty, x, y; for(t=k; t g[y][x] && ans[y][x]+1 > ans[ty][tx]) { ans[ty][tx] = ans[y][x] + 1; if(max < ans[ty][tx]) max = ans[ty][tx]; dfs(ty*c+tx, 1); } } if(ans[y][x]>0) return; } } } int main() { int i, j; freopen("1088.in", "r", stdin); scanf("%d%d", &r, &c); for(i=0; i