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 <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 <a, b> is appeared in continuous frames, it will form features movement. For example,

feature <a , bb > is appeared in frame2,3,4,7,8, then 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 n (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 satisfy N≤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 徐州赛区网络预赛

 

分析:T 个事例,每个事例包括 n 行,每行第一个是 m,代表后面有 m 个 <x, y>  。

          求:连续出现的 <x, y> 最多连续出现多少行。

          用STL乱搞一下就好,然而!

          神仙一样的题意.....猜到死都没猜出来.....自闭了

          啊啊啊....为什么会有英语这种东西,被自己菜哭了。 

 

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
//ll qpow(ll x, ll y, ll mod){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}

const int maxn = 1e6+5;

pair<int,int> p;
map<pair<int,int>,int>mp[2]; //因为是求连续出现,只需要记录前一行和当前这行的就ok

int main()
{
    int t,n,m,x,y;
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        int ans = 0, tmp = 0;
        for(int i=0;i<n;i++)
        {
            scanf("%d", &m);
            mp[tmp].clear();
            while(m--){
                scanf("%d%d",&x,&y);
                p = make_pair(x, y);
                if(mp[tmp^1].count(p)){
                    mp[tmp][p] = mp[tmp^1][p]+1;
                    ans = max(ans, mp[tmp][p]);
                }
                else{
                    mp[tmp][p] = 1;
                    ans = max(ans, mp[tmp][p]);
                }
            }
            tmp ^= 1;
        }
        printf("%d\n", ans);

    }

    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值