RAINBOWA - Editorial

Exactly !!
Here is Link to my AC solution Which gives Yes for above testcase.

https://www.codechef.com/viewsolution/14868106

Were test cases for RAINBOWA Weak?

Access denied! You don’t have permissions for this page.

the above test case 1 1 1 2 2 3 3 3 3 2 2 1 1 is not a rainbow array because rainbow array should go until it hits 7 and it should have all 1 2 3 4 5 6 7 without a skip over value.(1 2 4 5 6 7 6 5 4 2 1)(this is not a rainbow array)
(1 2 3 4 5 6 7 6 7 6 5 4 3 2 1 ) (this is also not a rainbow array either).

thanks bro for giving me some good explaination of test cases
can you plz tell me about this case 1 2 3 4 5 6 7 7 6 5 4 3 2 1 and its length is 14 is it “Yes” or “No”

Yes it is a rainbow. check here https://www.codechef.com/viewsolution/24013588

hi… my solution works https://www.codechef.com/viewsolution/24069803 BUT I have a question:

I had to comment following code:

# if iNoOfElements % 2 == 0:
# print(“no”)
# continue

Note: iNoOfElements is equal to N (provided as Input)

above code is in the beginning. Idea is if the array is a palindrome, it has to be an odd number

if I remove above code, the answer is accepted. I am not able to understand. Can someone please help.

Here is my solution. Not sure what is wrong

https://www.codechef.com/viewsolution/24352653

Please can someone explain this how?

This also not rainbow array 1 2 3 4 5 6 7 7 6 5 4 3 2 1

please Tell Me What is problem with my code

i already take care of every base case

#include
using namespace std;
#include<bits/stdc++.h>
int main() {

int t;
cin>>t;
while(t--)
{
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    int start=1;
    int end=n;
    int flag=1;
    while(start<=end)
    {
        int val1= arr[start]-arr[start+1];
        int val2=arr[end]-arr[end-1];
        if(val1!=val2 || (val1<-1 && val2<-1) || (arr[start]>7 || arr[end]>7))
        {
            flag=0; // not beautiful
            break;
        }
        start++;
        end--;
    }
    if(flag==0)
    cout<<"no"<<"\n";
    else
    cout<<"yes"<<"\n";
    
}
return 0;

}

Guys please help i do all my effort and thinking but i checked 40 testcase my code giving right answer but if get fails in codechef please help me friends

#include
using namespace std;
#include<bits/stdc++.h>
int main() {

int t;
cin>>t;
while(t--)
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int start=0;
    int end=n-1;
    int flag=1; //assume the already rainbow
    while(start<=end)
    {
          if(arr[start]!=arr[end] || arr[start]>7 || arr[end]>7)
          { 
                flag=0;
                break;
          }
          
          start++;
          end--;
    }
    if(flag==0)
    cout<<"no"<<"\n";
    else
    cout<<"yes"<<"\n";
    
}
return 0;

}

Over a month late, but looking at your most recent submission - consider the testcase:

1  
13  
1 3 3 4 5 6 7 6 5 4 3 3 1

Edit:

May as well post my solution - it’s unusually terse, for me, as I got the C++ Standard Library to do all the heavy-lifting :slight_smile: