• Features Track 2018徐州icpc网络赛 思维


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

      
     
     
    题意:n个集合,每个集合有ki个点,问连续在多个集合中出现的次数最多的点的次数
    分析:用一个map存下每个点的最后一次出现位置和连续出现次数,连续出现次数通过最后一次出现位置来判断,每次更新连续出现次数时取下最大值
    AC代码:
    #include <map>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <queue>
    #include <cstdio>
    #include <vector>
    #include <string>
    #include <bitset>
    #include <cstring>
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #define ls (r<<1)
    #define rs (r<<1|1)
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    typedef long long ll;
    const ll maxn = 1e5+10;
    const ll mod = 2e9+7;
    const double pi = acos(-1.0);
    const double eps = 1e-8;
    map<ll,pair<ll,ll> >mp;
    map<ll,ll> mm;
    int main() {
        ll k, n, a, b, T;
        scanf("%lld",&T);
        while( T -- ) {
            scanf("%lld",&n);
            ll maxa = 0;
            mp.clear();
            for( ll i = 1; i <= n; i ++ ) {
                scanf("%lld",&k);
                mm.clear();
                while( k -- ) {
                    scanf("%lld%lld",&a,&b);
                    ll t = a*mod + b; //通过乘mod将每个坐标转化成一个不同的值
                    if( mp[t].first == i-1 ) {
                        mp[t].second = mp[t].second + 1, mp[t].first = i;
                    } else if( mm[t] ) {
                        continue;
                    } else {
                        mp[t].second = 1, mp[t].first = i;
                    }
                    mm[t] ++;
                    maxa = max(maxa,mp[t].second);
                }
            }
            if( maxa == 1 ) {
                maxa = 0;
            }
            printf("%lld
    ",maxa);
        }
        return 0;
    }
    

      

  • 相关阅读:
    集群临时重启
    elasticsearch索引目录设置
    elasticsearch索引路径规则
    spring boot 使用application.properties 进行外部配置
    ELASTICSEARCH健康red的解决
    Elasticsearch——使用_cat查看Elasticsearch状态
    vmstat命令
    ava Maven项目之Nexus私服搭建和版本管理应用
    android 2.2 videoView 诡异bug
    华为部分设备运行很卡的问题
  • 原文地址:https://www.cnblogs.com/l609929321/p/9614809.html
Copyright © 2020-2023  润新知