set的自定义排序
看下面的代码就好了
struct cmp{
bool operator() (const pair<int,int>& a,const pair<int,int> &b)const{
int lena=a.second-a.first+1;
int lenb=b.second-b.first+1;
if(lena==lenb)
return a.first<b.first;
return lena>lenb;
}
};
int main()
{
set<pair<int,int>,cmp> t;
}

浙公网安备 33010602011771号