can't submit this code

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;
}
1 Like

Hi! In the given code above, you are missing a newline after printing “yes” or “no” everytime. If there is still an error, then mention.
Actually this problem can be easily solved with a stack. It is also solvable using an array, but it will be more elegant to use a stack for such a problem.
Here is a link to my AC solution. Though I used an array and not a stack. Hope this helps. :slight_smile:

thanks for answering but adding a new line doesn’t help. I saw your solution but I wanted to see my mistake here.