zoukankan      html  css  js  c++  java
  • 2018 徐州网络赛 F

    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_ixix_jxj and y_iyi = y_jyj, then <x_ixiy_iyi> <x_jxjy_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-4234 and 7-878 .

    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(1T10) , 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_ikifeatures 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 100000N100000 .

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


    思路:

    暴力。注意处理同一个颜色在一帧画面上出现两次的情况。

    #include <bits/stdc++.h>
    #define pii pair<int,int>
    using namespace std;
    map<pii,int> Map;
    vector<int> V[100005];
    int T,n,k,ans,cnt,tmp,x,y,tot;
    void output() {
        for (int i=1;i<=tot;++i) {
            for (int j=0;j<V[i].size();++j) printf("%d ",V[i][j]);
            printf("
    ");
        }
    }
    int main()
    {
        scanf("%d",&T);
        while (T--) {
            Map.clear();
            for (int i=1;i<=100000;++i) V[i].clear();
            tot=0;
            scanf("%d",&n);
            if (n==0) {
                printf("0
    ");
                continue;
            }
            for (int i=1;i<=n;++i) {
                scanf("%d",&k);
                while (k--) {
                    scanf("%d%d",&x,&y);
                    if (!Map[pii(x,y)]) Map[pii(x,y)]=++tot;
                    V[Map[pii(x,y)]].push_back(i);
                }
            }
            ans=0;
            //output();
            for (int i=1;i<=tot;++i) {
                cnt=1;
                ans=max(ans,cnt);
                for (int j=1;j<V[i].size();++j) {
                    if (V[i][j]==V[i][j-1]) continue;
                    else if (V[i][j]==V[i][j-1]+1) {
                        cnt++;
                        ans=max(ans,cnt);
                    } else {
                        cnt=1;
                    }
                }
            }
            //if (ans==1) ans=0;
            printf("%d
    ",ans);
        }
        return 0;
    View Code

     

  • 相关阅读:
    Codechef之2014FebChallenge
    Codechef之CodeCraft: IIIT Hyderabad
    原创水题
    用图论模型解决dp问题
    [某模拟赛]一道好题
    萌新java入门笔记
    CodeForces 761C 【DP】
    POJ3268【最短路】
    POJ3191【(-2)进制本质】
    POJ3264 【RMQ基础题—ST-线段树】
  • 原文地址:https://www.cnblogs.com/acerkoo/p/9638091.html
Copyright © 2011-2022 走看看