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 cfdream at 2007-05-28 13:05:42 on Problem 1088
#include<iostream>
#include<map>
#include<memory>
using namespace std;
int p[100][100];
int r[4]={1,-1,0,0};
int l[4]={0,0,1,-1};
struct node
{
	int w,i,j;
};
struct ltstr
{
   bool operator()(const node s1, const node s2) const 
   {
   	   return s1.w<s2.w;
   }
};
void main()
{
	map<const node,int,ltstr> ele;
	int R,L,v;
	cin>>R>>L;
	node pij;
	for(int i=0;i<R;i++)
		for(int j=0;j<L;j++)
		{
			cin>>pij.w;
			p[i][j]=pij.w;
			pij.i=i;
			pij.j=j;
			ele[pij]=0;
		}
	map<const node,int,ltstr>::iterator cur=ele.begin();
	(*cur).second=1;
	int max=(*cur).second;
	int x,y;
	for(i=1;i<R*L;i++)
	{
		int pox,poy;
		cur++;
		x=(*cur).first.i;
		y=(*cur).first.j;
		for(int m=0;m<4;m++)
		{
			pox=x+r[m];
			poy=y+l[m];
			if(pox>=0&&pox<R&&poy>=0&&poy<L)
			{
				node temp;
				temp.w=p[pox][poy];
				temp.i=pox,temp.j=poy;
				map<const node,int,ltstr>::iterator obj=ele.find(temp);
				if(temp.w<(*cur).first.w)
					if((*obj).second>=(*cur).second)
						(*cur).second=(*obj).second+1;
			}
		}
		if((*cur).second==0)
			(*cur).second=1;
		if((*cur).second>max)
			max=(*cur).second;
		//cout<<(*cur).first.w<<"  "<<(*cur).second<<endl;
	}
	cout<<max<<endl;
}

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