| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
同志们,看看问题在哪里啊?/////////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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator