acwing1944.记录保存
acwing.1944记录保存
原题链接:https://www.acwing.com/problem/content/1946/
思路
将三头牛放到一个vector里,然后用哈希表来记录出现的次数
代码
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main()
{
int n;
cin >> n;
map<vector<string>,int> hash;
for(int i = 0; i < n; i ++)
{
vector<string> cows(3);
for(int i = 0; i < 3; i ++) cin >> cows[i];
sort(cows.begin(),cows.end());
hash[cows] ++;
}
int ans = 0;
for(auto& [e,v] : hash)
{
ans = max(v,ans);
}
cout << ans;
return 0;
}
rds_blogs