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

求助!!discuss里的数据都过了,可就是wa,请各位牛人帮帮忙啊!!

Posted by luoyepiaoxu at 2010-02-26 22:55:54 on Problem 1088
#include<iostream>
#include<algorithm>
using namespace std;
int a[200][200],map[200][200]={0};
int i,j,k,l,ma=0;
struct zuo
{
	int x,y;
};
zuo b[40000];
bool pan(zuo xx,zuo yy)
{
	return (map[xx.x][xx.y]>map[yy.x][yy.y]);
}
int main()
{
	int xx,yy;
	cin>>xx>>yy;
	for(i=0;i<xx;i++)
	{
		for(j=0;j<yy;j++)
			a[i][j]=1;
	}
	for(i=0;i<xx;i++)
	{
		for(j=0;j<yy;j++)
		{
			cin>>map[i][j];
			b[i*xx+j].x=i;
			b[i*xx+j].y=j;
		}
	}
	sort(&b[0],&b[xx*yy],pan);
	int ch[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
	for(i=0;i<xx*yy;i++)
	{
		for(j=0;j<4;j++)
		{
			if(b[i].x+ch[j][0]>=0&&b[i].x+ch[j][0]<xx&&b[i].y+ch[j][1]>=0&&b[i].y+ch[j][1]<yy&&map[b[i].x][b[i].y]>map[b[i].x+ch[j][0]][b[i].y+ch[j][1]])
			{
				if(a[b[i].x][b[i].y]+1>a[b[i].x+ch[j][0]][b[i].y+ch[j][1]])
				   a[b[i].x+ch[j][0]][b[i].y+ch[j][1]]=a[b[i].x][b[i].y]+1;
			}
		}
	}
	for(i=0;i<xx;i++)
	{
		for(j=0;j<yy;j++)
		{
			if(ma<a[i][j])
				ma=a[i][j];			
		}
	}
	cout<<ma<<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