The problem is this
After going through the submitted solution, I found the answer is this-> w! * b! * (w -1)* C(w + b — 3, n — 3)
Can someone please explain how this solution is coming.
Thanks!
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 151 |
Name |
---|
Lets split the final arrangement as ABC. A,C both have good events and B has not-so-good events. Now, within A,C the good events can occur in any order which is given by w! and within B, the not-so-good events can occur in any order which is given by b!
Now, assume we have only good events "GGGGGG" (some random arrangement) and the not-so-good events separately "BBBB" (again some random arrangement). We have to insert the not-so-good events somewhere in the good events such that we can get ABC. Since, we need atleast one event in each of A, B and C and we have w good events totally, we have (w - 1) positions to insert the bad events.
Till now we have w! * b! * (w - 1) which takes care of the different arrangements of the good and not-so-good events as described. The last thing we need to calculate is the number of ways we can split each of this arrangement into the given number of days.
It is clearly given in the question that each day, only one type of event can occur, therefore AB or BC cannot occur on the same day. So, we must have a split like this A|B|C. Total number of positions to insert a split is w + b - 1 (-1 because we cannot insert a split before the first event) and since we have already inserted 2 splits, total number of positions available now would be w + b - 3. Now, each split will increase the number of days by 1 and by inserting the 2 splits initially we have already got 3 days and so we need to make n - 3 days which means we need to insert n - 3 splits, which equates to
So, finally we get the answer as
Hope it helps!
Can you please explain-> "since we have already inserted 2 splits"?
After we get a particular arrangement of the form ABC as described above where A,C have only good events and B has only not-so-good events, we need to separate the events into n days. But, we have an additional constraint saying that on each day only one type of event can occur. So, the last event in A and the first event in B must occur on different days. So, we have to insert a split between A and B. Similarly, the last event in B and first event in C must occur on different days, so we should also insert a split between B and C. So, we get A|B|C. Considering we have only this separation we have 3 days where A occurs on day 1, B occurs on day 2 and C occurs on day 3. Any further insertion of splits will increase the day by 1 and since we already have 3 days, we need to insert n - 3 more. Hope it is clear now.
Thanks