这份代码极限卡过 #11 :
#include<iostream>
#include<cstdio>
using namespace std;
long long t,q,n,ans,x,y,i;
int main()
{
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
long long where[150001]={},where2[14]={};
for(i=1;i<=n;i++)
scanf("%lld",&x),where[where2[x]]=i,where2[x]=i;
scanf("%lld",&q);
while(q--)
{
scanf("%lld%lld",&x,&y);
ans=0;
for(i=x;i<=y;i++)
{
if(where[i]<x||where[i]>y)ans++;
else i=where[i];
}
printf("%lld\n",ans);
}
}
return 0;
}
