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

就这样

Posted by hnzhzs at 2019-09-07 15:40:03 on Problem 1088 and last updated at 2019-09-07 15:40:48
In Reply To:大神求解 Posted by:2801748509 at 2018-02-26 16:42:43
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#define N 101
using namespace std;

int map[N][N],len[N][N];
int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
int r,c;

int dp(int i,int j)
{
	if(len[i][j]!=0) return len[i][j];
	int maxx=0,s;
	for(int t=0;t<4;t++)
	{
		int x=i+dir[t][0],y=j+dir[t][1];
		if(x>=0&&x<r&&y>=0&&y<c&&map[x][y]<map[i][j])
		{
			s=dp(x,y);
			if(s>maxx) maxx=s;
		}
	}
	len[i][j]=maxx+1;
	return maxx+1;
}

int main()
{
	while(~scanf("%d%d",&r,&c))
	{
		int mx=-1;
		memset(len,0,sizeof(len));
		for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
		scanf("%d",&map[i][j]);
		for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
		{
			len[i][j]=dp(i,j);
			if(len[i][j]>mx) mx=len[i][j];
		}
		/*for(int i=0;i<r;i++)
		{
			for(int j=0;j<c;j++)
			printf("%d",len[i][j]);
			printf("\n");}*/
			printf("%d\n",mx);
	}
	return 0;
}
> 		tl++;res[cx][cy]=1;q[tl][0]=maxh;q[tl][1]=cy;q[tl][0]=cx;q[tl][2]=q[hd][2]+1;
> 		if(maxh==0)return;
> 	}
> }
> int main(){
> 	cin>>length>>wide;
> 	for(int i=1;i<=length;i++)
> 	   for(int j=1;j<=wide;j++)
> 	      cin>>map_high[i][j];
> 	maxx=map_high[1][1];bx=1;by=1;
> 	for(int i=1;i<=length;i++)
> 	   for(int j=1;j<=wide;j++)
> 	      if(map_high[i][j]>maxx){
> 	         maxx=map_high[i][j];
> 	         bx=i;by=j;
> 		  }
> 	bfs(bx,by);
> 	cout<<q[tl][2];
> 	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