亚洲区域赛网络赛-徐州站F题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38570571/article/details/82597330

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 NNwill 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

样例输出

扫描二维码关注公众号,回复: 3486279 查看本文章
3

题目大意就是给出n天路径,每天有m个坐标点 (x,y),然后题目要求输出最大的连续坐标(比如第一天 的 1 1 第二天也有1 1 第三天也有1 1那它们就是连续的坐标,长度为3 ,第三行的 2 2 和第四行的 2 2 连续,长度为 2,不过要输出最大的术即为3

思路直接用map记录前一天的坐标连续输了,然后枚举递推就能找出最大值,要用scanf,否则超时

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        map <string,int> q[100001];
        int n;
       scanf("%d",&n);
        int maxx=0;
        for(int i=1;i<=n;++i)
        {
            int m,x,y;
            scanf("%d",&m);
            for(int j=0;j<m;++j)
            {
               scanf("%d%d",&x,&y);
               char ss[35];
               sprintf(ss,"%d-%d",x,y);
                 string s=ss;
                q[i][s]=q[i-1][s]+1;
                maxx=max(maxx,q[i][s]);
            }
        }
        printf("%d\n",maxx);
    }

}

猜你喜欢

转载自blog.csdn.net/qq_38570571/article/details/82597330