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

题目来源

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

题意:每一个frame中都有k个坐标

问连续出现的坐标 连续的frame最长的是多少

思路:

很简单的一个暴力 给每一个动作都编号 记下都在哪些frame中出现过

然后排个序 从头到尾跑一遍

要注意一个动作可能在同一个frame中出现

WA了超级久 初始化没有写好

看来以后还是不能在毛概课上A题


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<set>
//#include<bits/stdc++.h>
#define inf 0x7f7f7f7f7f7f7f7f
using namespace std;
typedef long long LL; const int maxn = 1e5+ 100;
typedef pair<int, int> mpair;
map<mpair, int> mmap;
int t, n, cntid, cnt;
struct node{
int id, frame;
}feature[maxn]; bool cmp(node a, node b)
{
if(a.id == b.id){
return a.frame < b.frame;
}
else{
return a.id < b.id;
}
} void init()
{
mmap.clear();
for(int i = 0; i < maxn; i++){
feature[i].id = 0;
feature[i].frame = 0;
}
cntid = 0;
cnt = 0;
} int main()
{
cin>>t;
while(t--){
init();
scanf("%d", &n);
if(n == 0){
printf("0\n");
continue;
}
for(int i = 0; i < n; i++){
int k;
scanf("%d", &k);
for(int j = 0; j < k; j++){
int x, y;
scanf("%d%d", &x, &y);
mpair p = make_pair(x, y);
if(mmap.find(p) == mmap.end()){
mmap[p] = cntid++;
}
feature[cnt].id = mmap[p];
feature[cnt].frame = i;
cnt++;
}
} sort(feature, feature + cnt, cmp);
int ans = 1, tmp = 1;
for(int i = 0; i < cnt - 1; i++){
if(feature[i].id == feature[i + 1].id && feature[i].frame + 1 == feature[i + 1].frame){
tmp++;
}
else if(feature[i].id == feature[i + 1].id && feature[i].frame == feature[i + 1].frame){
continue;
}
else{
ans = max(ans, tmp);
tmp = 1;
}
}
ans = max(ans, tmp); printf("%d\n", ans);
}
return 0;
}

最新文章

  1. 拼图小游戏之计算后样式与CSS动画的冲突
  2. 最适合作为Java基础面试题之Singleton模式
  3. Swift - UIView,UItableView,Cell设置边框方法
  4. js基础练习一之tab选项卡
  5. const,readonly 这些你真的懂吗? 也许会被面试到哦。。。
  6. mysql备份与还原
  7. poj 3321:Apple Tree(树状数组,提高题)
  8. Asp.net中的ajax回调模式(ICallbackEventHandler)
  9. CSS3系列:魔法系列
  10. 【转】Cannot find -ltinfo when compiling android 4.0.3
  11. Java笔记(八)&hellip;&hellip;数组
  12. Drainage Ditches(Dinic最大流)
  13. 实现基于Memcache存储的Session类
  14. Android软件盘InputMethodManager
  15. wince开发环境搭建与全套教程
  16. [进程管理] 理解 Linux 的处理器负载均值
  17. EOS智能合约授权限制和数据存储
  18. Codeforces Round #534 (Div. 2)D. Game with modulo-1104-D(交互+二分+构造)
  19. Scrum Meeting day 4
  20. MySQL单行注释和多行释

热门文章

  1. Android ListView 笔记
  2. Ironic , Openstack Baremetal Hypervisor
  3. linux下安装dovecot
  4. JavaSE集合(八)之Map
  5. 很好的hadoop学习博客实际操作训练(旧版本)
  6. url传参错误的痛
  7. makefile--参数传递、条件判断、include (五)
  8. Spring Framework 官方文档学习(四)之Validation、Data Binding、Type Conversion(一)
  9. GeoServer安装说明-OpenSpirit
  10. lua知识点整理