Files
python/TangDou/Mkx/20241125/YueHan.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

44 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
map<string, int> b;
/*
测试用例:
5
BESSIE ELSIE MATILDA
FRAN BESSIE INGRID
BESSIE ELSIE MATILDA
MATILDA INGRID FRAN
ELSIE BESSIE MATILDA
答案:
3
*/
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) { // 共n组
map<string, int> a; // 声明一个map用来将每组三个字符串进行整理顺序
for (int j = 1; j <= 3; j++) { // 每组3个
string s;
cin >> s;
a[s] = 1; // 由于a是一个有序map,所以进入map的自动就是排序的
}
// 把在map中的字符串键值使用迭代器进行逐个输出,拼接成一个新的字符串,这个新的字符串一定是顺序固定的
string se = "";
for (auto it = a.begin(); it != a.end(); it++)
se = se + " " + it->first;
// cout << "sorted string =" << se << endl;
// 将整理完顺序的字符串做为key放入到map的b中
b[se]++;
}
// 使用迭代器输出b里面的内容看一下
int mx = 0;
for (auto it = b.begin(); it != b.end(); it++)
mx = max(mx, it->second);
cout << mx << endl;
return 0;
}