# Can someone explain me this question from codeforces...

I am sorry,this might sound stupid,but recently I saw a question on codeforces and was unable to deduce what the question wants to say,trying to think how to solve is another thing but I am not even able to understand the statement,I am new to competititve programming,please help,
Thankyou

He drew the last ball of colour i before drawing the last ball of colour i + 1 for all i from 1 to k - 1.

Let us consider k=3 and one ball of each kind.
#c1=1, #c2=1, #c3=1;
Here you cannot draw c2 before c1 and c3 before c2. so, only one order is possible i.e, (c1, c2, c3).

Now let us consider 4 balls like this #c1=1, #c2=2, #c3=1
This case has 2 orders are possible
(c1, c2, c2, c3) and (c2, c1, c2, c3).

I hope this clears your doubt.

1 Like

The problem statement is kind of confusing.

What the problem setter wanted to convey was-

He sees that before every (i+1)th color ball, he drew ball of color i. In how many ways can it happen?

Eg- In input

``````3
2
2
1
``````

3= Number of colors.

Now problem statement says that he drew the LAST ball of color (i+1)th before the LAST BALL i th color.

Meaning-

Before last ball of color 2, he drew the last ball of color 1. Before last Ball of color 3, he drew the last ball of color 2.

Look at the given configurations-

``````1 2 1 2 3
1 1 2 2 3
2 1 1 2 3
``````

Before drawing last ball of 2, he drew last ball of 1 in all 3 (meaning before finishing balls of (i+1)th color in bag, he finishes ball of i th color ALWAYS).

Similarly he drew last ball of 2 before drawing last ball of 3.

Thanks a lot,this problem statement was very confusing but I get it now…

1 Like