Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
数据太弱了。。。。写得如此垃圾也能过。。。抱着必TLE之心提交。。竟然AC。。。280MS。。。#include<iostream> using namespace std; #define MAX 301 int main() { int R, C, i, j; int map[MAX][MAX]; int f[MAX][MAX]; cin >> R >> C; memset(map, 0, sizeof(map)); memset(f, 0, sizeof(f)); for(i = 1; i <= R; i ++) for(j = 1; j <= C; j ++) cin >> map[i][j]; for(i = 1; i <= R; i ++) for(j = 1; j <= C; j ++) f[i][j] = 1; int sign = 1; while(sign == 1) { sign = 0; for(i = 1; i <= R; i ++) for(j = 1; j <= C; j ++) { if(map[i][j] > map[i - 1][j] && f[i][j] <= f[i - 1][j]) { f[i][j] = f[i - 1][j] + 1; sign = 1; } if(map[i][j] > map[i + 1][j] && f[i][j] <= f[i + 1][j]) { f[i][j] = f[i + 1][j] + 1; sign = 1; } if(map[i][j] > map[i][j - 1] && f[i][j] <= f[i][j - 1]) { f[i][j] = f[i][j - 1] + 1; sign = 1; } if(map[i][j] > map[i][j + 1] && f[i][j] <= f[i][j + 1]) { f[i][j] = f[i][j + 1] + 1; sign = 1; } } } int max = -1; for(i = 1; i <= R; i ++) for(j = 1; j <= C; j ++) if(f[i][j] > max) max = f[i][j]; cout << max << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator