| ||||||||||
| 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 | |||||||||
Re:这一题的数据好容易通过呀!!!!In Reply To:这一题的数据好容易通过呀!!!! Posted by:knuthocean at 2005-03-16 10:02:49 测试数据是对的,可是不能AC,帮帮忙...
#include <iostream.h>
#include <algorithm>
#include <vector>
using std::vector;
using std::sort;
struct CPoint
{
int x;
int y;
};
bool cmp1 ( CPoint t1, CPoint t2 )
{
return t1.x < t2.x;
}
bool cmp2 ( CPoint t1, CPoint t2 )
{
return t1.y < t2.y;
}
void computer(vector<CPoint>&cENum)
{
bool F;
int pos;
int nMNum=0;
while (1)
{
F=false;
pos=-1;
for (int i=0;i<cENum.size();i++)
{
if (cENum[i].y!=-1)
{
pos=i;
F=true;
break;
}
}
if (F==false)
{
break;
}
nMNum++;
for (int j=pos+1;j<cENum.size();j++)
{
if (cENum[j].y>=cENum[pos].y)
{
if (cENum[j].x>=cENum[pos].x)
{
cENum[pos].y=-1;
pos=j;
}
}
}
cENum[pos].y=-1;
}
if (nMNum!=0)
{
printf("%d\n",nMNum);
}
}
int main(int argc, char* argv[])
{
int nNum;
scanf("%d",&nNum);
for (int i=0;i<nNum;i++)
{
int nENum;
scanf("%d",&nENum);
vector<CPoint>cENum;
cENum.reserve(nENum);
for (int j=0;j<nENum;j++)
{
CPoint temp;
scanf("%d",&temp.x);
scanf("%d",&temp.y);
cENum.push_back(temp);
}
sort(cENum.begin(),cENum.end(),cmp1);
sort(cENum.begin(),cENum.end(),cmp2);
computer(cENum);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator