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

版权声明:Dream_dog专属 https://blog.csdn.net/Dog_dream/article/details/82563046

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

题解:巨水的一道题只要判断当前的feature在前面连续出现的次数就好然后更新ans   直接爆力


#include<cstring>
#include<cstdio>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<functional>
using namespace std;
#define clr(a,b) memset(a,b,sizeof(a))
#define lowbit(x) x&-x
#define rep(a,b,c) for(ll a=b;a<c;a++)
#define dec(a,b,c) for(int a=b;a>c;a--)
#define eb(x) emplace_back(x)
#define pb(x) push_back(x)
#define ps(x) push(x)
#define _INIT ios::sync_with_stdio(false);cin.tie(nullptr);cout.precision(10);cout<<fixed
#define MAX_N 100000+5
#define MAX_M 100
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<ll,vector<ll>,greater<ll> >pqg;
const ll maxn=1e3;
const ll inf=1e7;
struct Node
{
    int ti,x,y;
};
vector<Node> ve[MAX_N];
int main()
{
#ifndef ONLINE_JUDGE
    // freopen("data.txt","r",stdin);
#endif
    //_INIT;
    int t;
    scanf("%d",&t);
    while(t--)
    {
        clr(ve,0);
        int n,ans=0;
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
        {
         int k;scanf("%d",&k);
         while(k--)
         {
             Node tm;scanf("%d%d",&tm.x,&tm.y);tm.ti=i;
             for(int j=0;j<ve[i-1].size();j++)
             {
                 if(ve[i-1][j].x==tm.x&&ve[i-1][j].y==tm.y){tm.ti=ve[i-1][j].ti;break;}
             }
             ve[i].push_back(tm);
             ans=max(ans,i-tm.ti+1);
         }
        }
        printf("%d\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Dog_dream/article/details/82563046