【ACM-ICPC 2018 徐州赛区网络预赛】F题 Features Track ---- STL应用(暴力)

版权声明:本文为博主原创文章,转载请预先通知博主(〃'▽'〃)。 https://blog.csdn.net/m0_37624640/article/details/82624996

题目链接

做法:使用STL map+pair 暴力模拟即可,注意避免同一帧有相同特征的情况

代码:

#include<bits/stdc++.h>
#define IO          ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb(x)       push_back(x)
#define sz(x)       (int)(x).size()
#define sc(x)       scanf("%d",&x)
#define pr(x)       printf("%d\n",x)
#define abs(x)      ((x)<0 ? -(x) : x)
#define all(x)      x.begin(),x.end()
#define mk(x,y)     make_pair(x,y)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const double PI = 4*atan(1.0);
const int maxm = 1e8+5;
const int maxn = 1e5+5;
const int INF = 0x3f3f3f3f;
typedef pair<ll,ll> PII;
map<PII,int> m[maxn];
map<PII,int> ans;
map<PII,int> vis;
int main()
{
    #ifdef LOCAL_FILE
    freopen("in.txt","r",stdin);
    #endif // LOCAL_FILE
    IO;
    int t,n,k;;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int res = -1;
        ans.erase(ans.begin(),ans.end());
        for(int i=0;i<=n;i++) m[i].erase(m[i].begin(),m[i].end());
        for(int i=1;i<=n;i++)
        {
            cin>>k;
            vis.erase(vis.begin(),vis.end());
            if(k == 0)
            {
                ll x = (1ll<<32);
                ll y = (1ll<<32);
                PII p(x,y);
                m[i][p]++;
            }
            for(int j=1;j<=k;j++)
            {
                int x,y;
                cin>>x>>y;
                PII p(x,y);
                m[i][p]++;
                if(m[i-1].count(p) == 1 && vis[p] == 0)
                {
                    ans[p]++;
                    vis[p]++;
                    res = max(res,ans[p]);
                }
                else if(m[i-1].count(p) == 0) ans[p] = 0;
            }
        }
        cout<<res+1<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37624640/article/details/82624996