题意: 给定n个长度为m的数字序列,统计有多少种不同的数字序列。要求按照同一种类的个数的降序排序,如果两种序列的个数相同,按照数字序列大小的升序排序。 思路: map维护数量,最后赛到set里排序。重载set排序,涨知识.(虽然直接数组排也一样) 代码:
#include
using namespace std;
const int N = 1e4+10;
int n,m,k,T;
//-------------------------------
struct cmp{
bool operator() (const pair & a,const pair &b)
{
if(a.second != b.second)
{
return a.second > b.second;
}
return a.first >n>>m;
for(int i=0;iva[j];
}
mp[va] ++ ;
}
for(auto item:mp)
{
sa.insert({item.first,item.second});
}
cout
关注
打赏