版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yz467796454/article/details/82588465
题目链接:https://nanti.jisuanke.com/t/31458
样例输入
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
题意:t组样例,n帧,k个特征,每个特征是二维向量,求最长连续出现的特征的长度,<a,b><b,a>是不同的特征
思路:题目理解了,就暴力模拟吧
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
struct node{
int x,y;
int sum;
}pre[100005],now[100005];
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int ans=0;
int k;
scanf("%d",&k);
int tot=0;
for(int i=1;i<=k;i++){
scanf("%d%d",&pre[tot].x,&pre[tot].y);
pre[tot].sum=1;
tot++;
}
for(int i=2;i<=n;i++){
scanf("%d",&k);
int cnt=0;
for(int j=1;j<=k;j++){
scanf("%d%d",&now[cnt].x,&now[cnt].y);
now[cnt].sum=1;
cnt++;
}
for(int j=0;j<cnt;j++){
for(int p=0;p<tot;p++){
if(now[j].x==pre[p].x&&now[j].y==pre[p].y){
now[j].sum=pre[p].sum+1;
}
}
}
tot=0;
for(int j=0;j<cnt;j++){
pre[tot++]=now[j];
ans=max(ans,now[j].sum);
}
}
printf("%d\n",ans);
}
return 0;
}