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 <xx, yy>. If x_ixi​ = x_jxj​and y_iyi​ = y_jyj​, then <x_ixi​, y_iyi​> <x_jxj​, y_jyj​> 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,82,3,4,7,8, then it forms two features movement 2-3-42−3−4 and 7-87−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 \le T \le 10)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 k_iki​ ( the number of features) and 2k_i2ki​intergers describe k_iki​ 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 NNwill satisfy N \le 100000N≤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个集合,每个集合有ki个点,问连续在多个集合中出现的次数最多的点的次数
分析:用一个map存下每个点的最后一次出现位置和连续出现次数,连续出现次数通过最后一次出现位置来判断,每次更新连续出现次数时取下最大值
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e5+10;
const ll mod = 2e9+7;
const double pi = acos(-1.0);
const double eps = 1e-8;
map<ll,pair<ll,ll> >mp;
map<ll,ll> mm;
int main() {
ll k, n, a, b, T;
scanf("%lld",&T);
while( T -- ) {
scanf("%lld",&n);
ll maxa = 0;
mp.clear();
for( ll i = 1; i <= n; i ++ ) {
scanf("%lld",&k);
mm.clear();
while( k -- ) {
scanf("%lld%lld",&a,&b);
ll t = a*mod + b; //通过乘mod将每个坐标转化成一个不同的值
if( mp[t].first == i-1 ) {
mp[t].second = mp[t].second + 1, mp[t].first = i;
} else if( mm[t] ) {
continue;
} else {
mp[t].second = 1, mp[t].first = i;
}
mm[t] ++;
maxa = max(maxa,mp[t].second);
}
}
if( maxa == 1 ) {
maxa = 0;
}
printf("%lld\n",maxa);
}
return 0;
}

  

Features Track 2018徐州icpc网络赛 思维的更多相关文章

  1. Trace 2018徐州icpc网络赛 思维+二分

    There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) ...

  2. Ryuji doesn't want to study 2018徐州icpc网络赛 树状数组

    Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, ea ...

  3. Trace 2018徐州icpc网络赛 (二分)(树状数组)

    Trace There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx ...

  4. ICPC 2018 徐州赛区网络赛

    ACM-ICPC 2018 徐州赛区网络赛  去年博客记录过这场比赛经历:该死的水题  一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进.     D. Easy Math 题意:   ...

  5. ACM-ICPC 2018 徐州赛区(网络赛)

    目录 A. Hard to prepare B.BE, GE or NE F.Features Track G.Trace H.Ryuji doesn't want to study I.Charac ...

  6. Supreme Number 2018沈阳icpc网络赛 找规律

    A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...

  7. 2019 徐州icpc网络赛 E. XKC's basketball team

    题库链接: https://nanti.jisuanke.com/t/41387 题目大意 给定n个数,与一个数m,求ai右边最后一个至少比ai大m的数与这个数之间有多少个数 思路 对于每一个数,利用 ...

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

    262144K   Morgana is learning computer vision, and he likes cats, too. One day he wants to find the ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心)

    ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心) Trace 问答问题反馈 只看题面 35.78% 1000ms 262144K There's a beach in t ...

随机推荐

  1. 设置Myeclipse的jvm内存参数

    Myeclipse经常会遇到内存溢出和Gc开销过大的情况,这时候就需要修改Myeclipse的Jvm内存参数 修改如下:(使用Extjs做公司大项目时候,不要让项目Builders的Javascrip ...

  2. 用多个分隔符切分字符串---re.split()

    问题/需求: 需要将字符串切分,但是分隔符在整个字符串中并不一致 (即:需要用多个分隔符切分字符串) str.split()方法不可行: 只支持单一分隔符,不支持正则及多个切割符号,不感知空格的数量 ...

  3. [NUnit]No results

    Results (nunit3) saved as TestResult.xmlCommitting...No results, this could be for a number of reaso ...

  4. SpringBoot 2 HTTP转HTTPS

    @Bean public TomcatServletWebServerFactory servletContainer() { TomcatServletWebServerFactory tomcat ...

  5. appcan IDE 无法 请求数据

    我们4月27号从4.0.1升级到4.0.2后,IDE本地预览get请求不到数据.但是在线打包安装到手机又是正常的. 先下载 "uexXmlHttpMgr.rar",下载链接:htt ...

  6. LeetCode——372. Super Pow

    题目链接:https://leetcode.com/problems/super-pow/description/ Your task is to calculate ab mod 1337 wher ...

  7. android——SQLite数据库存储(操作)

    public class MyDatabaseHelper extends SQLiteOpenHelper { //把定义SQL建表语句成字符串常量 //图书的详细信息 //ID.作者.价格.页数. ...

  8. pythonday03数据类型(一)

    今日内容 1.整型 2.布尔型 3.字符串 4.补充 5.作业讲解 6,pycharm自动生成头文件 1.整型(int) py2 int/long 32位电脑:-2147483648-21474836 ...

  9. mysql注意事项

    注意事项: 1.查询条件内需要使用时间的,不要使用数据库函数now(),都使用应用服务器传入: 2.所有id为mysql自增的,需要使用创建时间排序,都使用order by id desc;或者根据查 ...

  10. 洛谷 P2787 语文1(chin1)- 理理思维

    题意简述 维护字符串,支持以下操作: 0 l r k:求l~r中k的出现次数 1 l r k:将l~r中元素赋值为k 2 l r:询问l~r中最大连续1的长度 题解思路 珂朵莉树暴力赋值,查询 代码 ...