计蒜客 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,询问 ...
随机推荐
- jsp电子商务 购物车实现之二 登录和分页篇
登录页面核心代码 <div id="login"> <h2>用户登陆</h2> <form method="post" ...
- Angular白名单&&Angular拦截器 全局通用
//angular 白名单全局通用 app.config([ '$compileProvider', function ($compileProvider) { $compileProvider.aH ...
- bootstrap、angularJS、nodeJs、reactJs视频教程
bootstrap.angularJS.nodeJs.reactJs视频教程 发布时间:『 2017-06-25 19:50』 博客类别:资源下载 阅读(74) 评论(0) 智能社与达内哪个好?说 ...
- Python3 urlparse
>>> from urllib.parse import urlparse >>> o = urlparse('http://www.cwi.nl:80/%7Egu ...
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...
- Windows下查看某个端口被哪个服务占用
1.查看某个端口是否被占用 打开命令行,输入:netstat -ano | findstr "3306" 2.查看端口被哪个服务占用 tasklist | findstr “PID ...
- WebOS系列-了解Wekbit【邓侃】
注:[转载请注明文章来源.保持原样] 出处:http://www.cnblogs.com/jyli/archive/2010/02/02/1660634.html 作者:李嘉昱 这是Kan老大的We ...
- css3 新旧伸缩盒的异同
由于不需要理会IE浏览器,伸缩盒(flexible box)移动端开发中非常好用! 工作中使用APICLOUD开发手机App,老板要求兼容到安卓2.3(新版的需要安卓4.4以上),所以一直使用的是旧版 ...
- HDU1878 欧拉回路---(并查集+图论性质)
http://acm.hdu.edu.cn/showproblem.php?pid=1878 欧拉回路 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- 【SPOJ-QTREE3】树链剖分
http://www.spoj.com/problems/QTREE3/ 时间限制:2s 代码长度限制:50000B 内存限制:1536MB [题目描述] 给出N个点的一棵树(N-1条边 ...