ICPC 2018 徐州网络预赛 F Features Track
样例输入
1
8
2 1 1 2 2
2 1 1 1 4
2 1 1 2 2
2 2 2 1 4
0
0
1 1 1
1 1 1
样例输出
3
解题思路
纯暴力,STL的使用,一行中出现相同的pair要去重!!!
AC代码
#include <iostream>
#include <map>
#include <utility>
#include <cstring>
#include <algorithm>
using namespace std;
pair<int, int>p;
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
map<pair<int, int>, int >mm;
int n, t, a, b, maxn = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
map<pair<int, int>, int >book;//与上一次结果连接
map<pair<int, int>, int >flag;//一行 去重
scanf("%d", &t);
while (t--)
{
scanf("%d%d", &a, &b);
p = make_pair(a, b);
if (flag[p] == 0)
{
mm[p]++;
flag[p] = 1;
}
maxn = max(maxn, mm[p]);
book[p] = 1;
}
for (auto it = mm.begin(); it != mm.end(); it++)
if (book[it->first] == 0)
mm[it->first] = 0;
}
printf("%d\n", maxn);
}
}