hello,
I’ve working on a problem :code: RAINBOWA and i seem to be having a difficulty in submitting the code. Given below is my code.Can someone help me out what test case I might be missing.
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
bool b = true;
bool midflag=true;
int mid= (int)(n+1)/2;
vector <int>v,vv;
for(int i=0;i<mid-1;i++){
int temp;
cin>>temp;
if(temp>7)
b=false;
v.push_back(temp);
}
int middle;
cin>>middle;
if(!(n%2)){
v.push_back(middle);
midflag=false;
if(middle!=7)
b=false;
}
for(int i=mid;i<n;i++){
int temp;
cin>>temp;
if(temp>7)
b=false;
vv.push_back(temp);
}
reverse(vv.begin(),vv.end());
if(v.size()==vv.size()){
for(int i=0;i<vv.size();i++){
if(v[i]!=vv[i])
b=false;
}
int pre=1,next;
for(int i=0;i<vv.size()-1;i++){
next=pre+1;
if((v[i]!=pre)&&(v[i]!=next))
b=false;
if(v[i]==next){
pre=next;
}
}
if(midflag){
if((middle-vv[vv.size()-1]!=1)||(middle-v[v.size()-1]!=1))
b=false;
if(middle!=7)
b=false;
}
}else{
b=false;
}
if(v[0]!=1)
b=false;
if(b)
cout<<"yes";
else
cout<<"no";
/*cout<<v.size()<<vv.size();
*/
}
return 0;
}