容器,不解释
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
const int N=1000115;
int dp[N];
set<int>s;
int main()
{
int t, n;
cin>>t;
while(t--)
{
s.clear();
cin>>n;
for(int i=0; i<n; i++)
{
cin>>dp[i];
}
int l=0, r=0, ans=0;
while(r<n)
{
while(r<n&&!s.count(dp[r]))
{
s.insert(dp[r++]);
}
ans=max(ans,r-l);
s.erase(dp[l++]);
}
cout<<ans<<endl;
}
return 0;
}