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\n",maxa);
    }
    return 0;
}

  

转载于:https://www.cnblogs.com/l609929321/p/9614809.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值