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 bluenight at 2006-07-12 20:35:35 on Problem 1065
/////////1065
#include<iostream>
using namespace std;
struct POINT
{
	int  length,weight,mark;
};
POINT point[5000];
void  findpoint(POINT & p,int num,int& state)
{
	 bool m=false;	
	 for(int i=0;i<num;i++)
	  if(point[i].mark<0&&point[i].mark!=state&&p.length<=point[i].length&&p.weight<=point[i].weight)
	  {
		 point[i].mark=state;
		 p.length=point[i].length;
		 p.weight=point[i].weight;
		 p.mark=point[i].mark;
         m=true;
		 break;
	 }
	  if(m)
		 findpoint(p,num,state);
	  else if(m==false && p.mark>=-1) {state++;return ;}
	 else return ;
}
int main()
{
    int testcase,num,i,j;
	POINT temp;
	cin>>testcase;
	while(testcase-->0)
	{
       cin>>num;
	   for(i=0;i<num;i++)
	   {
		  cin>>point[i].length>>point[i].weight;
		  point[i].mark=-1;
	   }
        for(i=0;i<num-1;i++)
			for(j=i;j<num;j++)
				if(point[j].length<point[i].length)
				{
					temp=point[j];
                    point[j]=point[i];
					point[i]=temp;
				}
				int count=0;
		   for(i=0;i<num;i++)
			  if(point[i].mark==-1)
			    findpoint(point[i],num,count);
			cout<<count<<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