RAINBOWA - Editorial

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

Better

It now fails on the following test input:

1
13
2 2 3 4 5 6 7 6 5 4 3 2 2
2 Likes

got it
Thanks

1 Like

My code: Rainbowa

I’m not able to find the test case that is getting failed. Someone please help me with this code.

Will the list contain elements valued only upto 7 or can it take up values like 8 9 also? Like is
1 2 3 4 4 5 6 7 7 8 7 7 6 5 4 4 3 2 1 valid??

1 2 3 4 4 5 6 7 7 8 7 7 6 5 4 4 3 2 1 is not valid. The array can contain elements only upto 7

1 Like

Hello everyone,
I am unable to find out why my code gives a WA. Can someone please help me.
https://www.codechef.com/viewsolution/36204637

@ssjgz