zoukankan      html  css  js  c++  java
  • 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;
    }
    

      

  • 相关阅读:
    PHP:第四章——PHP数组转换,统计,相关函数
    PHP:第四章——PHP数组添加,删除,插入,分割,合并,及运算符
    小程序追加数据的实现方法
    小程序获取当前日期和时间
    小程序获取用户的登录头像和用户名
    PHP:第四章——数组中的排序函数
    PHP:第三章——数组中的array_values
    PHP:第一章——PHP中静态变量和常量
    红帽企业版RHEL7.1在研域工控板上,开机没有登陆窗口 -- 编写xorg.conf 简单三行解决Ubuntu分辩率不可调的问题
    本地方法中printf如何传给java--java系统级命名管道
  • 原文地址:https://www.cnblogs.com/l609929321/p/9614809.html
Copyright © 2011-2022 走看看