GENIE SEQUENCE(SPOJ)
Here is the my solution :-
//siddharth prasad
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <cmath>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define FOR(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define fst first
#define snd second
#define max(a,b)(a>b?a:b)
int main()
{
int t;
cin>>t;
while(t--)
{
int n,i,flag=0,x;
cin>>n;
int a[1000]={0};
for(i=0;i<n;i++)
{
cin>>x;
if(a[x+1]==0)
{
a[x+1]=1;
flag++;
}
else if(a[n-x]==0)
{
a[n-x]=1;
flag++;
}
}
if(flag==n)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
return 0;
}
No comments:
Post a Comment