第一次写题解哈哈哈,用的STL
#include <bits/stdc++.h>
using namespace std;
// 自定义哈希函数
struct SetHash {
size_t operator()(const set<int>& s) const {
size_t hash = 0;
for (int x : s) {
hash ^= hash_combine(hash, x);
}
return hash;
}
size_t hash_combine(size_t a, int b) const {
return a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2));
}
};
int main() {
int n;
cin >> n;
unordered_map<set<int>, int, SetHash> result; // 使用自定义哈希函数
int max_count = 0;
for (int i = 0; i < n; i++) {
set<int> path;
int a, b, c;
cin >> a >> b >> c;
path.insert(a);
path.insert(b);
path.insert(c);
// 使用 operator[] 来更新计数
result[path]++;
if (result[path] > max_count) {
max_count = result[path];
}
}
cout << max_count << endl;
return 0;
}