Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

数据太弱了。。。。写得如此垃圾也能过。。。抱着必TLE之心提交。。竟然AC。。。280MS。。。

Posted by vince4053040 at 2010-03-04 21:44:02 on Problem 1088
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator