### uva 11572 唯一的雪花 Unique Snowflakes

```/**==========================================
*   This is a solution for ACM/ICPC problem
*
*   @source£º
*   @type:
*   @author: wust_ysk
*   @blog:  http://blog.csdn.net/yskyskyer123
*   @email: 2530094312@qq.com
*===========================================*/
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#define REP(i,n)  for(int i=0 ;i<(n) ;i++)
using namespace std;
typedef long long ll;
const int INF =0x3f3f3f3f;
const int maxn= 1000000   ;
struct Node
{
int ind,x,y;
bool operator<(const Node b)const
{
return ind<b.ind;
}

}a[maxn+4];

bool cmp(Node c,Node b)
{
return c.x<b.x;
}
int n;

struct MyQueue
{
int front,rear;
bool vis[maxn+4];
void clear()
{
front=rear=0;
memset(vis,0,n*sizeof vis[0]);
}
int size()
{
return rear-front;
}
void push(int y)
{
if(!vis[y])
{
rear++;
vis[y]=1;
return;
}
while(a[front].y!=y )
{
vis[a[front].y]=0;
front++;
}
front++;
rear++;

}

}Q;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
REP(i,n)
{
scanf("%d",&a[i].x);
a[i].ind=i;
}
sort(a,a+n,cmp);
REP(i,n)
{
a[i].y=i;
int t=i;
while(i+1<n&&a[i+1].x==a[i].x)
{
a[++i].y=t;
}
}
sort(a,a+n);
Q.clear();
int ans=0;
REP(i,n)
{
int y=a[i].y;
Q.push(y);
ans=max(ans,Q.size());
}
printf("%d\n",ans);
}

return 0;
}
```