RAINBOWA! [trying since 2 days]

Hello!
QUESTION HERE

I’ve thinking, been debugging about this question since some days. BUT NO FRUITS!.
It is passing the example but NOT the cases can SUPERHUMAN spot the problem .

LOGIC:-

  1. check if first and last and moving backward and towards front, elements are equal
    2)Check if the count of any number that comes in the range of the middle element is NOT ZERO
#include <bits/stdc++.h>
using namespace std;

int main()
{

    int t;
    cin>>t;
    ++t;
    while(--t)
    {
        int l,el,mpos;

        cin>>l;
        vector<int> v;
        bool flag1=0,flag2=0;
        for(int i =0;i<l;++i)
        {
            cin>>el;
            v.push_back(el);

        }
        if(l%2!=0)
        {
            mpos=((l+1)/2)-1;

        }else{
            mpos = (l/2)-1;
        }

        for(int i = 1;i<=v.at(mpos);++i) // checked for missing piece
        {
            if (count(v.begin(),v.end(),i) == 0){
                flag1 = 0;
                break;
            }else{
            flag1 = 1;


            }
        }

    // cond-2
    int sz = v.size();
    for(int i=1;i<sz;++i)
    {
        if(v[i-1]!=v[sz-i])
        {
            flag2=0;
            break;
        }
        else{
        flag2 = 1;}


    }





    if(flag1==0 or flag2==0){
    cout<<"no"<<"\n";
    }
    else{
        cout<<"yes"<<"\n";
    }





    }

}

1 Like

It is giving NO which is correct ig

Aha ! i just read your comments on the editorial. I had mis understood the statement.

1 Like