poj 1083 Moving Tables

#include <iostream>
#include
<algorithm>
using namespace std;
struct node
{
int x,y;
bool operator<(const node& o)
{
return x<o.x;
}
}ans[
300];
int main()
{
int t,n,i,s,tag[300];
cin
>>t;
while(t--)
{
cin
>>n;
int a,b;
for(i=0;i<n;++i)
{
cin
>>a>>b;
if(a>b)
swap(a,b);
if(a%2==0)
a
=a/2-1;
else
a
=a/2;
if(b%2==0)
b
=b/2-1;
else
b
=b/2;
ans[i].x
=a;ans[i].y=b;
}
sort(ans,ans
+n);
memset(tag,
0,sizeof(tag));
int r,c=0;
s
=0;
while(c<n)
{
r
=-1;
for(i=0;i<n&&c<n;++i)
{
if(tag[i]||ans[i].x<=r)
continue;
c
++;
tag[i]
=1;
r
=ans[i].y;
}
s
++;
}
cout
<<10*s<<endl;
}
return 0;
}

  

posted on 2011-07-22 16:58  sysu_mjc  阅读(134)  评论(0编辑  收藏  举报

导航