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

题目来源

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

 

题意:给你n个视频片段,每个片段有ki帧图片<x,y>,问在n个片段中连续出现的图片的最长长度是多少。【与该帧图片出现的位置无关,只与出现在第几个视频中有关】

思路:将x,y,出现在第几个视频中pos进行排序。判断相同的<x,y>是否连续和连续长度。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
struct node
{
    int x,y;
    int pos;
} ff[maxn];
bool cmp(node&a,node&b)
{
    if(a.x==b.x&&a.y==b.y)return a.pos<b.pos;
    if(a.x==b.x)return a.y<b.y;
    return a.x<b.x;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int cnt=0;
        for(int v=0;v<n;v++)
        {
            int k;scanf("%d",&k);
            int a,b;

            for(int i=0;i<k;i++)
            {
                scanf("%d%d",&a,&b);
                ff[cnt].x=a;
                ff[cnt].y=b;
                ff[cnt].pos=v;
                cnt++;
            }
        }
        sort(ff,ff+cnt,cmp);
        int ans=1,num=1;
        for(int i=1;i<cnt;i++)
        {
            //printf("x=%d,y=%d,pos=%d\n",ff[i].x,ff[i].y,ff[i].pos);
            if(ff[i].x==ff[i-1].x&&ff[i].y==ff[i-1].y&&ff[i].pos==ff[i-1].pos+1)num++;
            else if(ff[i].x==ff[i-1].x&&ff[i].y==ff[i-1].y&&ff[i].pos==ff[i-1].pos);
            else num=1;

            ans=max(num,ans);
        }
        if(cnt==0)ans=0;
        printf("%d\n",ans);
    }
}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值