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 <aa, bb> is appeared in continuous frames, it will form features movement. For example, feature <aa , bb > is appeared in frame 2,3,4,7,8then 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 nn (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 satisfyN≤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 徐州赛区网络预赛

【题目大意】有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y)。两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别相等。求最多连续相同特征的个数?

【题解】用一个map来维护帧中特征的信息,map中的键即读入的向量,因此用一个pair<int , int>表示,键的值也是一个pair,需要记录它当前已经连续了多少次,还需要记录它上一次出现的帧的位置。如果它上一帧没有出现过,那么它的连续次数就要被置成1;如果上次出现了,则继续累加。用ans维护某个键最大连续出现次数。

map<pair<int ,int> , pair<int ,int>>

map[ pair(x,y)].first为该特征(x.y)连续次数

map[ pair(x,y)].second为该特征上一次出现的帧序号,用于下一次判断连续性

#include<bits/stdc++.h>
using namespace std;#define e exp(1)
#define pi acos(-1)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define mem(a,b) memset(a,b,sizeof(a))
int gcd(int a,int b){return b?gcd(b,a%b):a;}typedef pair<int,int> pii;
map<pii,pii> mp;
int main()
{int T;scanf("%d",&T);while(T--){int n;scanf("%d",&n);int ans=-1;for(int i=1; i<=n; i++){int k;scanf("%d",&k);for(int j=1; j<=k; j++){int x,y;scanf("%d%d",&x,&y);if(mp[pii(x,y)].second==i-1)mp[ pii(x,y) ].first++;else if(mp[pii(x,y)].second==i)continue;else mp[ pii(x,y) ].first = 1;ans=max(ans,mp[pii(x,y)].first);mp[pii(x,y)].second=i;}}printf("%d\n",ans);}return 0;
}

ACM-ICPC 2018 徐州赛区网络预赛 Features Track(STL二维map)相关推荐

  1. ACM-ICPC 2018 徐州赛区网络预赛 D. Easy Math

    Easy Math 问答问题反馈 只看题面 16.47% 1000ms 262144K Given a positive integers nn , Mobius function \mu(n)μ(n ...

  2. ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath

    ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath 做法: \[f(m,n) = \sum _{i=1}^{m} \mu(in) = \sum_{i=1}^{m}[gcd(i,n)= ...

  3. ACM-ICPC 2018 徐州赛区网络预赛G (单调队列)

    传送门 题面: There's a beach in the first quadrant. And from time to time, there are sea waves. A wave (  ...

  4. ACM-ICPC 2018 徐州赛区网络预赛 - A. Hard to prepare - (计数递归)

    题目链接 After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deli ...

  5. ACM-ICPC 2018 徐州赛区网络预赛 I. query 树状数组

    I. query 题目链接: Problem Description Given a permutation \(p\) of length \(n\), you are asked to answe ...

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

    BE, GE or NE 题意: 每一轮有三种操作, 加上a 减去b 或者 取负 当且仅当 a, b, c 不为0时,对应的操作有效; 给出一个上界和一个下界 大于等于上界就是 Good Ending ...

  7. ACM-ICPC 2018 徐州赛区网络预赛 Morgana Net

    题意:Morgana Net 题解:把a矩阵每一位根据公式推出递推矩阵,然后用矩阵快速幂,比赛没想到啊,, #include<bits/stdc++.h> #define ll long ...

  8. Easy Math(ACM-ICPC 2018 徐州赛区网络预赛)(递归 + 杜教筛)

    Easy Math 推式子 ∑i=1mμ(in)∑i=1mμ(i×nd×d),d是n的一个质因子i,d互质项有(−∑i=1mμ(i×nd)),由于减去了多余的非互质项,所以加上,−∑i=1mμ(i×n ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 I. Characters with Hash

    注意几种情况,前导零是不要的:如果在开头的第一个值为个位数,那么占一位,如果个位数出现在中间,那么占两位,比如6就是06 #include <iostream> #include < ...

最新文章

  1. java 3维_java 二维/三维/多维数组
  2. 《上海市产业绿贷支持绿色新基建(数据中心)发展指导意见》印发了
  3. 启明云端直播来了!真的来了!15号晚7:30分启明云端带着8ms菇凉正式亮相立创直播,带你一起畅玩彩屏!参与直播互动的小伙伴将会得到红包大奖及获得SigmarstarSSD201开发板\核心板的机会
  4. 整理一周的Python全品类资料包含100本电子书,还有独家实战项目源码公开!
  5. ***客户端出现“无法完成连接尝试”的解决方法
  6. 如何查询 ABAP 传输请求(Transport Request)和使用该请求修改了的程序的信息?
  7. “vector”: 不是“std”的成员_libcxx 的 std::function 源码分析
  8. [渝粤教育] 扬州工业职业技术学院 微言品语文 参考 资料
  9. Web安全测试实战之测试HTTP方法
  10. wxpython使窗口重新显示_wxpython刷新窗口按按钮
  11. 《AutoCAD 2013中文版从入门到精通》—— 导读
  12. 用python给游戏加上音效_添加声音到你的Python游戏
  13. WinRAR 5.40无弹窗广告注册版下载
  14. 游戏测试流程及工作内容
  15. 20190131-JS - Promise使用详解--摘抄笔记
  16. Chromium浏览器不能播放MP4
  17. andorid自动化测试之Monkey(上)
  18. 静态网页/动态网页/伪静态网页/动态HTML
  19. LeetCode:三数之和
  20. asp.net html silverlight 传参数,Silverlight和ASP.NET相互传参的两种常用方式(QueryString,Cookie)...

热门文章

  1. 获取jar包内部的资源文件
  2. Cstring转化为String
  3. 数据结构之通过C++来实现一个队列
  4. JQuery的无缝滚动
  5. 重拾Javascript (四) KnockoutJs使用
  6. [导入]做了一个页面静态化小软件,和大家分享,up有分
  7. 详细解释CNN卷积神经网络各层的参数和链接个数的计算
  8. .+filename的作用
  9. android 蓝牙传输分包,彻底掌握Android多分包技术(一)
  10. win10下gnuplot的安装