题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6570
dp[i][j]表示,目前为止,以j i为循环节,i结尾的wave有多长,明显dp[i][j]=dp[j][i]+1
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[105][105],ans=1;
int N,C,X;
int main()
{
scanf("%d%d",&N,&C);
for(int i=1;i<=N;i++)
{
scanf("%d",&X);
for(int j=1;j<=C;j++)
{
dp[X][j]=dp[j][X]+1;
if(X!=j)//奇偶位不能相同
ans=max(ans,dp[X][j]);
}
}
printf("%lld\n",ans);
return 0;
}