AcWing 729. 特征提取
原题链接
中等
作者:
沙漠绿洲
,
2020-10-05 19:49:36
,
所有人可见
,
阅读 404
C++ 代码
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
struct pos{
int x, y;
bool operator==(const pos& p) const{
return x == p.x && y == p.y;
}
};
struct hashhelp
{
std::size_t operator()(const pos& p) const{
return std::hash<int>()(p.x);
}
};
int main()
{
unordered_map<pos, vector<int>, hashhelp> hasha;
int n, m;
cin >> m;
for(int i = 0; i < m; ++ i)
{
cin >> n;
for(int j = 0; j < n; ++ j)
{
int a, b;
cin >> a >> b;
hasha[{a, b}].push_back(i);
}
}
int ret = 0;
for(auto& x : hasha){
vector<int>& ans = x.second;
int res = 1, cnt = 1;
for(int i = 1; i < ans.size(); ++ i){
if(ans[i] == ans[i - 1] + 1) ++ cnt;
else cnt = 1;
res = max(res, cnt);
}
ret = max(ret, res);
}
cout << ret << endl;
return 0;
}