清点代码库
作者:
晴斋
,
2024-03-07 13:35:22
,
所有人可见
,
阅读 26
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
map<vector<int>, int> mp;
vector<pair<int,vector<int>>>ans;
int main()
{
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i ++)
{
vector<int>ve;
for (int j = 1; j <= m; j ++)
{
int x;
scanf("%d", &x);
ve.push_back(x);
}
mp[ve] ++;
}
cout << mp.size() << endl;
for (auto item : mp) ans.push_back({-item.second, item.first});
//这题最后是先输出最大的,但是sort排序是从小到大,所以这里用了负号
sort(ans.begin(), ans.end());
for (auto item : ans)
{
cout << -item.first << ' ';
for (auto i : item.second) cout << i << ' ';
cout << endl;
}
return 0;
}