#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000009];
bool c[100009];
int main()
{
ll i,j,k,l,m,n,test,arr[100009];
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
memset(a,0,sizeof(a));
memset(c,0,sizeof(c));
bool flag=1;
for(i=0;i<n;i++)
{
cin>>arr[i];
a[arr[i]]++;
if(a[arr[i]]>2)
{
flag=0;
}
if(arr[i]>=n)
{
flag=0;
}
}
sort(arr,arr+n);
if(!flag)
{
cout<<"Case "<<k<<": "<<"no"<<endl;
continue;
}
ll gar=-9999999;
for(i=0;i<n;)
{
if(!flag)
break;
ll tmp=arr[i];
if(a[tmp]==1)
{
//cout<<11111<<" "<<tmp<<endl;
if(c[tmp]==0)
{
c[tmp]=1;
}
else
{
flag=0;
}
i=i+1;
}
else
{
//cout<<22222<<" "<<tmp<<endl;
if(c[tmp]==0&&c[n-tmp-1]==0)
{
c[tmp]=1;
c[n-tmp-1]=1;
}
else
{
flag=0;
}
i=i+2;
}
}
cout<<"Case "<<k<<": ";
if(flag)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
using namespace std;
typedef long long ll;
ll a[1000009];
bool c[100009];
int main()
{
ll i,j,k,l,m,n,test,arr[100009];
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
memset(a,0,sizeof(a));
memset(c,0,sizeof(c));
bool flag=1;
for(i=0;i<n;i++)
{
cin>>arr[i];
a[arr[i]]++;
if(a[arr[i]]>2)
{
flag=0;
}
if(arr[i]>=n)
{
flag=0;
}
}
sort(arr,arr+n);
if(!flag)
{
cout<<"Case "<<k<<": "<<"no"<<endl;
continue;
}
ll gar=-9999999;
for(i=0;i<n;)
{
if(!flag)
break;
ll tmp=arr[i];
if(a[tmp]==1)
{
//cout<<11111<<" "<<tmp<<endl;
if(c[tmp]==0)
{
c[tmp]=1;
}
else
{
flag=0;
}
i=i+1;
}
else
{
//cout<<22222<<" "<<tmp<<endl;
if(c[tmp]==0&&c[n-tmp-1]==0)
{
c[tmp]=1;
c[n-tmp-1]=1;
}
else
{
flag=0;
}
i=i+2;
}
}
cout<<"Case "<<k<<": ";
if(flag)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
No comments:
Post a Comment