ACM-ICPC 2018 徐州赛区网络预赛 F. Features Track

时间:2023-03-09 07:50:03
ACM-ICPC 2018 徐州赛区网络预赛    F. Features Track
  • 262144K

Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat movement from a cat video.

To do this, he extracts cat features in each frame. A cat feature is a two-dimension vector <x, y>. If xi​= xj​ and yi​ = yj​, then <xi​, yi​> <xj​, yj​> are same features.

So if cat features are moving, we can think the cat is moving. If feature <a, b> is appeared in continuous frames, it will form features movement. For example,

feature <a , bb > is appeared in frame2,3,4,7,8, then it forms two features movement 2−3−4 and 7−8 .

Now given the features in each frames, the number of features may be different, Morgana wants to find the longest features movement.

Input

First line contains one integer T(1≤T≤10) , giving the test cases.

Then the first line of each cases contains one integer n (number of frames),

In The next nn lines, each line contains one integer ki​ ( the number of features) and 2ki​ intergers describe ki​features in ith frame.(The first two integers describe the first feature, the 33rd and 44th integer describe the second feature, and so on).

In each test case the sum number of features N will satisfy N≤100000 .

Output

For each cases, output one line with one integers represents the longest length of features movement.

样例输入复制

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

题目来源

ACM-ICPC 2018 徐州赛区网络预赛

 #define  P pair<int,int>
using namespace std;
int t,n,k;
int x,y;
map<P,int>mp[];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int maxx=;
mp[].clear();
mp[].clear();
int last=;
for(int i=;i<=n;i++)
{
last=-last;//滚动
scanf("%d",&k);
for(int j=;j<=k;j++)
{
scanf("%d%d",&x,&y);
if(!mp[-last].count({x,y}) ){//因为必须连续的才有效
mp[last][{x,y}]=;
}
else{
mp[last][{x,y}]=mp[-last][{x,y}]+;
}
maxx=max(maxx,mp[last][{x,y}]);
}
mp[-last].clear();//继续滚动
}
printf("%d\n",maxx);
}
return ;
}