标签:os io for amp size ios sp algorithm
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
struct p{int a,b;};
bool cmp(p p1, p p2)
{
if(p1.b>p2.b) return true;
if(p1.b==p2.b && p1.a<p2.a) return true;
return false;
}
bool uni(p p1,p p2)
{
return p1.b==p2.b && p1.a==p2.a;
}
int main()
{
//freopen("1.txt","r",stdin);
int m;
cin>>m;
while(m--)
{
int n;
cin>>n;
vector<p> vec;
for (int i=1;i<=n;i++)
{
p p1;
cin>>p1.a>>p1.b;
if(p1.a>p1.b){int temp=p1.a;p1.a=p1.b;p1.b=temp;}
vec.push_back(p1);
}
sort(vec.begin(),vec.end(),cmp);
vector<p>::iterator p;
p=unique(vec.begin(),vec.end(),uni);
vec.erase(p,vec.end());
int count=1;
int a[1005];
a[0]=999;
for (int i=0;i< vec.size();i++)
{
for (int j=count-1;j>=0;j--)
{
if(vec[i].a<a[j])
{
a[j+1]=vec[i].a;
if(j+1==count) count++;
break;
}
}
}
cout<<count-1<<endl;
}
return 0;
}
标签:os io for amp size ios sp algorithm
原文地址:http://www.cnblogs.com/2014acm/p/3914383.html