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

Re:0 MS 代码附上

Posted by ds570 at 2017-04-06 20:41:31 on Problem 1088
In Reply To:0 MS 代码附上 Posted by:2016202202 at 2017-03-01 08:46:50
> #include<stdio.h>
> #include<string.h>
> #include<stdlib.h>
> #define N 128
> int a[N][N];
> int num[N][N];
> int n,m;
> 
> int dp(int i,int j)
> {
> 	if(a[i][j] != 0)return a[i][j];
> 	int maxn = 0;
> 	if(i - 1 > 0 && j > 0 && num[i][j] > num[i - 1][j] && dp(i - 1,j) > maxn)
> 	{
> 		maxn = a[i - 1][j];
> 	}
> 	if(i > 0 && j - 1 > 0 && num[i][j] > num[i][j - 1] && dp(i,j - 1) > maxn)
> 	{
> 		maxn = a[i][j - 1];
> 	}
> 	if(i > 0 && j + 1 <= n && num[i][j] > num[i][j + 1] && dp(i, j + 1) > maxn)
> 	{
> 		maxn = a[i][j + 1];
> 	}
> 	if(i + 1 <= m && j > 0 && num[i][j] > num[i + 1][j] && dp(i + 1,j) > maxn)
> 	{
> 		maxn = a[i + 1][j];
> 	}
> 	a[i][j] = maxn + 1;
> 	return a[i][j];
> }
> int main()
> {
> 	scanf("%d%d",&m,&n);
> 	for(int i = 1;i <= m;i ++)
> 	{
> 		for(int j = 1;j <= n;j ++)
> 		{
> 			scanf("%d",&num[i][j]);
> 		}
> 	}
> 	int max = 0;
> 	for(int i = 1;i <= m;i++)
> 	{
> 		for(int j = 1;j <= n;j ++)
> 		{
> 			a[i][j] = dp(i,j);
> 			if(max < a[i][j])
> 				max = a[i][j];
> 		}
> 	}
> 	printf("%d\n",max);
> }

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