F. Features Track

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 NN will 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

这道题目的意思就是猫有动作,一共有n个画面,每个画面有多个动作,第i行的第一个数表示该画面有几个动作,每个动作由两个数来确定。问你连续的画面中出现次数最多的动作出现了几次。

其实就是给每个动作一个映射的值,用map保存一下就可以,写个pair,然后对于连续的操作,就用滚动数组就可以,因为只有两种状态,所以直接开个2的数组就可以。我是用二维map写的,里面内嵌的pair,其实用结构体代替pair就可以,因为我懒,所以用的pair。
一开始写这道题的时候,因为数据感觉有点大,还想用hash来处理一下,结果发现,直接map硬怼就过了。。。
具体代码写了注释(再也不敢不写注释了。。。)
 
代码:
 //F-滚动数组+map连续计数
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; const double PI=acos(-1.0);
const double eps=1e-;
const ll mod=1e9+;
const int inf=0x3f3f3f3f;
const int maxn=1e5+;
const int maxm=1e3+;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); map<pair<int,int>,int> mp[];
map<pair<int,int>,int>p; int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int maxx=-;
for(int i=;i<n;i++){
int k;
scanf("%d",&k);
int t1=i%;//因为只有两种状态,当前和上一个,所以直接%2就可以
int t2=(i+)%;
mp[t1].clear();//清空
p.clear();
for(int j=;j<k;j++){
int u,v;
scanf("%d%d",&u,&v);
if(p[make_pair(u,v)]==){//如果在当前画面中该动作还没出现,就标记一下
p[make_pair(u,v)]=;
if(mp[t2][make_pair(u,v)]!=)//如果当前动作在上一个画面中出现过
mp[t1][make_pair(u,v)]=mp[t2][make_pair(u,v)]+;//直接上一个状态+1
else
mp[t1][make_pair(u,v)]++;//如果出现过了,直接++
maxx=max(maxx,mp[t1][make_pair(u,v)]);//找一下最大值
}
}
}
printf("%d\n",maxx);
}
}

溜了溜了。。。

计蒜客 31458.Features Track-滚动数组+STL(map)连续计数 (ACM-ICPC 2018 徐州赛区网络预赛 F)的更多相关文章

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

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

  2. ACM-ICPC 2018 徐州赛区网络预赛 F Features Track(STL模拟)

    https://nanti.jisuanke.com/t/31458 题意 有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别 ...

  3. 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)

    H.Ryuji doesn't want to study 27.34% 1000ms 262144K   Ryuji is not a good student, and he doesn't wa ...

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

    签到题 因为一个小细节考虑不到wa了两次 // 一开始没这个if wa了.因为数据中存在同一帧(frame)一个相同的值出现多次,这样子同一个i 后面的同样的特征会把len重置为1 #include ...

  5. ACM-ICPC 2018 徐州赛区网络预赛 H Ryuji doesn't want to study (树状数组差分)

    https://nanti.jisuanke.com/t/31460 题意 两个操作.1:查询区间[l,r]的和,设长度为L=r-l+1, sum=a[l]*L+a[l+1]*(L-1)+...+a[ ...

  6. ACM-ICPC 2018 徐州赛区网络预赛H Ryuji doesn't want to study(树状数组)题解

    题意:给你数组a,有两个操作 1 l r,计算l到r的答案:a[l]×L+a[l+1]×(L−1)+⋯+a[r−1]×2+a[r] (L is the length of [ l, r ] that ...

  7. ACM-ICPC 2018 徐州赛区网络预赛 G. Trace【树状数组维护区间最大值】

    任意门:https://nanti.jisuanke.com/t/31459 There's a beach in the first quadrant. And from time to time, ...

  8. ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study(树状数组)

    Output For each question, output one line with one integer represent the answer. 样例输入 5 3 1 2 3 4 5 ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 HRyuji doesn't want to study 树状数组

    题目链接:https://nanti.jisuanke.com/t/A2007 题目大意:有一个序列含有n个数a[1],a[2],a[3],……a[n],有两种操作: 第一种操作:k=1,l,r,询问 ...

随机推荐

  1. React & shit Antd

    React & shit Antd https://ant.design/components/tooltip-cn/ https://ant.design/components/tag-cn ...

  2. Python数据分析(二)pandas缺失值处理

    import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(5, 3), index=['a', 'c', 'e' ...

  3. 使用HTML5的JavaScript选择器操作页面中的元素

    <!doctype html><html lang="en"> <head>     <meta charset="UTF-8& ...

  4. 关于<meta http-equiv="Content-Type" content="text/html:charset=UTF-8">

    meta是html的元标签,其中包含了对应html的相关信息,客户端浏览器或服务端程序都会根据这些信息进行处理.我们以<meta http-equiv="Content-Type&qu ...

  5. [51nod1482]部落信号 单调栈

    ~~~题面~~~ 题解: 可以发现这是一道单调栈的题目,首先来考虑数字没有重复时如何统计贡献. 因为这是一个环,而如果我们从最高的点把环断开,并把最高点放在链的最后面(顺时针移动),那么因为在最高点两 ...

  6. 统计无符号整数二进制中1的个数(Hamming weight)

    1.问题来源 之所以来记录这个问题的解法,是因为在在线编程中经常遇到,比如编程之美和京东的校招笔试以及很多其他公司都累此不疲的出这个考题.看似简单的问题,背后却隐藏着很多精妙的解法.查找网上资料,才知 ...

  7. 自己模拟实现一下Google的赛马Doodle

    今天的Google Doodle是个动态的,是一个骑马的动态Doodle,是谷歌纪念英国实验摄影师埃德沃德·迈布里奇182周年诞辰,埃德沃德·迈布里奇是运动摄影的开创者,所以谷歌涂鸦以一个运动的摄影作 ...

  8. handler更新ui线程的基本用法

    1.因为费时操作要放子线程,更新UI要放UI线程(主线程),所以子线程和主线程通信,通信的话要用到handler这个东西. 这里讲的比较简单,举2个例子说明 2.使用post的是handler ,使用 ...

  9. jwplayer 部署方案1

    <body> <div id="my_player" data_src="http://xx.com/jwplayer/uploads/test.mp4 ...

  10. netty的Udp单播、组播、广播实例+Java的Udp单播、组播、广播实例

    网络上缺乏netty的udp的单播.组播案例,经过一番学习总结之后终于把这两个案例调通,下面把这两个案例的代码放在这里分享一下. 首先推荐博文: http://colobu.com/2014/10/2 ...