清点代码库

清点代码库,第1张

清点代码库

看了别的博主的说了一下y总  , 觉得这样写法短而且容易懂

主要就是容器的使用

#include"bits/stdc++.h"

using namespace std;
map,int>mp;
vector>>v;
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    while (n--)
    {
        vectorq;
        for(int i=0;i>x;
            q.push_back(x);
        }
        mp[q]++;
    }
    for(auto &i:mp) v.push_back({-i.second,i.first});    // -i.second 这里主要是让排序大到小
    sort(v.begin(),v.end());
    cout << mp.size() << endl;
    for(auto &i:v){
        cout << -i.first ;
        for(auto j:i.second){
            cout << " " << j;
        }
        cout << endl;
    }
    return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4653998.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-06
下一篇 2022-11-06

发表评论

登录后才能评论

评论列表(0条)

保存