计蒜客 31458.Features Track-滚动数组+STL(map)连续计数 (ACM-ICPC 2018 徐州赛区网络预赛 F)
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_i2ki intergers describe k_ikifeatures 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
这道题目的意思就是猫有动作,一共有n个画面,每个画面有多个动作,第i行的第一个数表示该画面有几个动作,每个动作由两个数来确定。问你连续的画面中出现次数最多的动作出现了几次。
//F-滚动数组+map连续计数
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; const double PI=acos(-1.0);
const double eps=1e-;
const ll mod=1e9+;
const int inf=0x3f3f3f3f;
const int maxn=1e5+;
const int maxm=1e3+;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); map<pair<int,int>,int> mp[];
map<pair<int,int>,int>p; int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int maxx=-;
for(int i=;i<n;i++){
int k;
scanf("%d",&k);
int t1=i%;//因为只有两种状态,当前和上一个,所以直接%2就可以
int t2=(i+)%;
mp[t1].clear();//清空
p.clear();
for(int j=;j<k;j++){
int u,v;
scanf("%d%d",&u,&v);
if(p[make_pair(u,v)]==){//如果在当前画面中该动作还没出现,就标记一下
p[make_pair(u,v)]=;
if(mp[t2][make_pair(u,v)]!=)//如果当前动作在上一个画面中出现过
mp[t1][make_pair(u,v)]=mp[t2][make_pair(u,v)]+;//直接上一个状态+1
else
mp[t1][make_pair(u,v)]++;//如果出现过了,直接++
maxx=max(maxx,mp[t1][make_pair(u,v)]);//找一下最大值
}
}
}
printf("%d\n",maxx);
}
}
溜了溜了。。。
计蒜客 31458.Features Track-滚动数组+STL(map)连续计数 (ACM-ICPC 2018 徐州赛区网络预赛 F)的更多相关文章
- ACM-ICPC 2018 徐州赛区网络预赛 F. Features Track
262144K Morgana is learning computer vision, and he likes cats, too. One day he wants to find the ...
- ACM-ICPC 2018 徐州赛区网络预赛 F Features Track(STL模拟)
https://nanti.jisuanke.com/t/31458 题意 有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别 ...
- 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)
H.Ryuji doesn't want to study 27.34% 1000ms 262144K Ryuji is not a good student, and he doesn't wa ...
- ACM-ICPC 2018 徐州赛区网络预赛 Features Track
签到题 因为一个小细节考虑不到wa了两次 // 一开始没这个if wa了.因为数据中存在同一帧(frame)一个相同的值出现多次,这样子同一个i 后面的同样的特征会把len重置为1 #include ...
- ACM-ICPC 2018 徐州赛区网络预赛 H Ryuji doesn't want to study (树状数组差分)
https://nanti.jisuanke.com/t/31460 题意 两个操作.1:查询区间[l,r]的和,设长度为L=r-l+1, sum=a[l]*L+a[l+1]*(L-1)+...+a[ ...
- ACM-ICPC 2018 徐州赛区网络预赛H Ryuji doesn't want to study(树状数组)题解
题意:给你数组a,有两个操作 1 l r,计算l到r的答案:a[l]×L+a[l+1]×(L−1)+⋯+a[r−1]×2+a[r] (L is the length of [ l, r ] that ...
- ACM-ICPC 2018 徐州赛区网络预赛 G. Trace【树状数组维护区间最大值】
任意门:https://nanti.jisuanke.com/t/31459 There's a beach in the first quadrant. And from time to time, ...
- ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study(树状数组)
Output For each question, output one line with one integer represent the answer. 样例输入 5 3 1 2 3 4 5 ...
- ACM-ICPC 2018 徐州赛区网络预赛 HRyuji doesn't want to study 树状数组
题目链接:https://nanti.jisuanke.com/t/A2007 题目大意:有一个序列含有n个数a[1],a[2],a[3],……a[n],有两种操作: 第一种操作:k=1,l,r,询问 ...
随机推荐
- 【python】time 和datetime类型转换,字符串型变量转成日期型变量
s1='20120125'; 6 s2='20120216'; 7 a=time.strptime(s1,'%Y%m%d'); 8 b=time.strptime( ...
- Bootstrap中轮播图
Bootstrap中轮播图插件叫作Carousel,为了清晰的表明每个标签在这里是什么意思,我把解释写在了下面的代码中. <!-- 以下容器就是整个轮播图组件的整体, 注意该盒子必须加上 cla ...
- 关于HTML中的object元素
<object>元素:它主要用于定义网页中的多媒体,比如音频,视频,Java applets,PDF,Active和Flash.object标签内除了param标签外,其他的内容将在浏览器 ...
- Luogu2737 USACO4.1麦香牛块(动态规划)
小凯的疑惑升级版.只有两个数的话不能表示的最大数是ab-a-b,显然如果可选数增加不会比这更大,所以只要答案存在一定小于256*256-2*256.在这个范围内背包即可. #include<io ...
- P3457 [POI2007]POW-The Flood
题意翻译 Description 你手头有一张该市的地图.这张地图是边长为 m∗n 的矩形,被划分为m∗n个1∗1的小正方形.对于每个小正方形,地图上已经标注了它的海拔高度以及它是否是该市的一个组成部 ...
- 【题解】Bzoj2560串珠子
挺强的……容斥+状压DP.首先想到如果可以求出f[k],f[k]代表联通状态为k的情况下的合法方案数,则f[k] = g[k] - 非法方案数.g[k]为总的方案数,这是容易求得的.那么非法方案数我们 ...
- URAL1696 Salary for Robots
题目戳这里. 最长下降子序列单调队列求法. \(f_{i,j,k}\)表示考虑前\(i\)个数,\(g_1 = j,g_2 = k\)的方案数.转移: \[f_{i,j,k} = \sum_{p = ...
- HDU 5670
Machine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- python异常之with
1.基本语法 with expression [as target]: with_body 参数说明: expression:是一个需要执行的表达式: target:是一个变量或者元组,存储的是exp ...
- 关于javascript中的this 一段小实例深有体会啊
先声明鄙人正在努力的把脚抬进门来,说的都是比较粗浅的知识,但都是我实践中得出的体会,很深刻. 正在自学中挣扎的DOG. 先看段代码: function highlightRows() { if(!d ...