RAINBOWA - Editorial

Should be no.

1 Like

but why? I am not being able to figure outā€¦

What is the value of a_7 for that testcase?

1 Like

There would not be an a7 for this oneā€¦
But this array is valid as the value of N is 7 hereā€¦ and a[i] is well within range??

The a_i's have to be non-zero positive integersm from the Problem statement.

1 Like

but how can there be an a7 for n=7? Can you please explain?

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

Hit like if you understand easily by my solution.
I think you will get clear understanding of o(n) solution after reading my solution.
Remember some examples in mind:
1 2 3 4 5 6 7 7 6 5 4 3 2 1 - yes
12 3 7 3 2 1-no
There are some exception always in your code if you are getting WA.
If you want any help in your code, you can ask simply by tagging me.

1 Like

There canā€™t - there are no Rainbow Arrays for n<13.

2 Likes

Hi prathameshmore, this seems to me as a Rainbow array. Can you point out exactly why this is not a rainbow array

Hi , please help . This code is outputting WA , where is the problem ?

My code for RAINBOWA problem

Consider the testcase:

1
7
1 2 3 7 3 2 1
2 Likes

The code works good. current_no=4 and next_no=5, which will break the loop after setting flag = False. Link for my code again for visibility here

On my machine, your solution outputs

yes

for the testcase I gave you.

3 Likes

Hi ssjgz, found the mistake thanks. The code still does not pass #Task0 but passes #Task1. I want to know mistake or test case for the solution to fail.

Code

1 Like

Consider the testcase:

1                   
14
1 2 3 4 5 6 8 7 6 5 4 3 2 1
1 Like

Thanks ssjgz. Found the mistakes. Was able to run both test cases correctly. Thanks for all the help.

1 Like

The problem is very poorly written!

https://www.codechef.com/viewsolution/33076407
can someone pls tell where i am getting it wrong ?
it gives WA.
suggestion for any test case

Your solution fails on the sample test input - your output has to match the expected output exactly, remember!

1 Like

just updated the link.
can you pls check again
https://www.codechef.com/viewsolution/33076407