ACM-ICPC2018徐州网络赛 Features Track(二维map+01滚动)
Features Track
- 31.32%
- 1000ms
- 262144K
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_jxj and y_iyi = y_jyj, then <x_ixi, y_iyi> <x_jxj, y_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-42−3−4 and 7-87−8.
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(1≤T≤10), 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 NN will satisfy N \le 100000N≤100000 .
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
题目来源
二维map记录当前行累积pair个数,因为只涉及到当前行与上一行的状态,因此采用01滚动map即可。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; map<int,map<pair<int,int>,int> > mp;
pair<int,int> p; int main()
{
int t,n,x,y,i,j,k;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
int ans=,xxx=;
for(int i=;i<n;i++){
scanf("%d",&k);
mp[xxx].clear();
while(k--){
scanf("%d%d",&x,&y);
p = make_pair(x,y);
if(mp[xxx^].count(p)){
mp[xxx][p] = mp[xxx^][p]+;
ans=max(ans,mp[xxx][p]);
}
else{
mp[xxx][p]=;
ans=max(ans,mp[xxx][p]);
}
}
xxx^=;
}
printf("%d\n",ans);
}
return ;
}
ACM-ICPC2018徐州网络赛 Features Track(二维map+01滚动)的更多相关文章
- 2018 ICPC 徐州网络预赛 Features Track (STL map pair)
[传送门]https://nanti.jisuanke.com/t/31458 [题目大意]有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向 ...
- 2018 ICPC 徐州网络赛
2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution ...
- 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)
query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...
- ICPC 2019 徐州网络赛
ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才 ...
- [徐州网络赛]Longest subsequence
[徐州网络赛]Longest subsequence 可以分成两个部分,前面相同,然后下一个字符比对应位置上的大. 枚举这个位置 用序列自动机进行s字符串的下标转移 注意最后一个字符 #include ...
- Codeforces 519D A and B and Interesting Substrings(二维map+前缀和)
题目链接:http://codeforces.com/problemset/problem/519/D 题目大意:给你一串字符串s仅由小写字母组成,并且对于'a'~'z'都给了一个值.求子串t满足t的 ...
- 记一次坑爹的golang 二维map判断问题
记一次坑爹的golang 二维map判断问题 2018年10月18日 23:16:21 yinnnnnnn 阅读数:32更多 个人分类: golang 版权声明:本文为博主原创文章,未经博主允许不 ...
- HDU 1263 二维map
题意:给出一份水果的交易表,根据地区统计出水果的交易情况. 思路:二维map使用. #include<cstdio> #include<string> #include ...
- 062 01 Android 零基础入门 01 Java基础语法 07 Java二维数组 01 二维数组应用
062 01 Android 零基础入门 01 Java基础语法 07 Java二维数组 01 二维数组应用 本文知识点:二维数组应用 二维数组的声明和创建 ? 出现空指针异常 数组的名字指向数组的第 ...
随机推荐
- Delphi String的散漫记录,真是知识无数,陷阱无数
真是膜拜Delphi C++ Builder编译器的作者们,要下多少苦功夫才能解决如此之多的问题,制造出一个神级作品给世人享用.另外以我的编程经验所能想到很麻烦但却是必须的还有两个地方,一个是Form ...
- vi中如何替换某字符成“回车”?
vi中如何替换某字符成“回车”? 在 vi 中::s/,/^M/g (you need to type CTRL-V <CR> to get a ^M here)VIM - Vi IMpr ...
- AR模型脱卡,unity端实现步骤详情
AR模型脱卡unity端实现具体步骤 AR模型脱卡的原理 利用一些unity端AR插件做AR应用.通常会有一个需求,当识别物消失的时候,将3D模型从识别物这个父物体上移除,显示在屏幕中央.那么原理就显 ...
- em、pt、px和百分比
浏览器默认的字体大小为100%=16px=12pt=1em px像素(Pixel):是固定大小的单元.相对长度单位.像素px是相对于显示器屏幕分辨率而言的.一个像素等于电脑屏幕上的一个点(是你屏幕分辨 ...
- 《C prime plus (第五版)》 ---第11章 字符串和字符串函数
11-1:字符串表示和字符串I/O 1.首先先通过一个整体的例子来初步了解建立,读入和输出字符串的几种方式. #include<stdio.h> #define MSG "你一定 ...
- POJ3415 Common Substrings —— 后缀数组 + 单调栈 公共子串个数
题目链接:https://vjudge.net/problem/POJ-3415 Common Substrings Time Limit: 5000MS Memory Limit: 65536K ...
- PHP的引用详解【转】
摘自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/09/10/2173092.html 官方文档: 1.引用是什么:http://ww ...
- hdu-5857 Median(水题)
题目链接: Median Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- codeforces 558A A. Lala Land and Apple Trees(水题)
题目链接: A. Lala Land and Apple Trees time limit per test 1 second memory limit per test 256 megabytes ...
- BZOJ1798:[AHOI2009]维护序列
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...