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 <xy>. If xixj and yi = yj, then <xiyi> <xjyj> are same features.

So if cat features are moving, we can think the cat is moving. If feature <ab> 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 234 and 78 .

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(1T10) , 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 kifeatures 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 N100000 .

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 徐州赛区网络预赛

 

 

复制代码
 1 #define  P pair<int,int>
 2 using namespace std;
 3 int t,n,k;
 4 int x,y;
 5 map<P,int>mp[2];
 6 int  main()
 7 {
 8     scanf("%d",&t);
 9     while(t--)
10     {
11         scanf("%d",&n);
12         int maxx=0;
13         mp[0].clear();
14         mp[1].clear();
15         int last=0;
16         for(int  i=1;i<=n;i++)
17         {
18             last=1-last;//滚动
19             scanf("%d",&k);
20             for(int  j=1;j<=k;j++)
21             {
22                 scanf("%d%d",&x,&y);
23                 if(!mp[1-last].count({x,y}) ){//因为必须连续的才有效
24                     mp[last][{x,y}]=1;
25                     }
26                     else{
27                         mp[last][{x,y}]=mp[1-last][{x,y}]+1;
28                     }
29                     maxx=max(maxx,mp[last][{x,y}]);
30             }
31             mp[1-last].clear();//继续滚动
32         }
33         printf("%d\n",maxx);
34     }
35     return   0;
36 }
复制代码

 

posted on   cltt  阅读(358)  评论(0编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示