Not able to get the right approch

I am doing this question from codeforces…
This is the question…
https://codeforces.com/contest/1328/problem/D
I am getting wrong answer…
This is my last submission of this question…
https://codeforces.com/contest/1328/submission/99293506
I don’t know where the logic is failing.
What should be the right approch.
Please see my code…

hello @ashishnnnnn

the logic is somewhat correct. can u pls explain ur odd case what exaclty u r doing in that.

this is what u can do ->
for odd case if u have found any two consecutive figures of same type then u can treate them as single figure and make the whole cycle of even length.
if all consecutve figures are different then simply put color 3 for the last figure.

@ashishnnnnn
image

check this test case u can clearly do it in 2 colors but urs is giving 3.

Yaa… I got…
I was applying some brute force type of method without considering the all caes…
Applying this idea…

One thing i want to ask…
I am practising a lot…But not improving much in the contest…
This thing discourage me.
what should i do… ??

@ashishnnnnn
happens with everyone and it will take some time so just keep upsolving and focus on learning instead of ratings.

Yes… I should follow that… But sometimes… comparison with others or not performing up to our own expectation… is something which… frustrate.
By the way …got solution got accepted of this question.
Thanks again :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.