With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | turmax | 3559 |
| 6 | tourist | 3541 |
| 7 | strapple | 3515 |
| 8 | ksun48 | 3461 |
| 9 | dXqwq | 3436 |
| 10 | Otomachi_Una | 3413 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 147 |
| 4 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 142 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?
| Название |
|---|



C is really trivial: // cnt is number of non-zero piles, k is number of piles. if(cnt==0 || (cnt==1 && k==1) || (cnt==k)) puts("Better luck next time!"); else puts("Happy Birthday Tutu!");
E is just matching, use hungarian method. P(one or more trip passing) = 1-P(non passing) = 1 — Product(i, 1 to n, p_f(i))) where f(i) is the best match permutation. So just compute matching matrix n^2, and use Hungarian, but fractions have to be carefuly not to overflow.
if(cnt==k)puts("Better luck next time!") which is not right for the second example.
Good point. In this case, it should be tutu wins, because he can reduce to 2 columns, with 1 stone in each. It's just a case handling problem.
how is that a winning move?
According to your method, if (cnt < 2) then prints("Better luck next time!"); which also is my thinking. But I'm still getting WA. :( I've run out of test cases. My primary method is
If cnt < 2 then Tutu can't make any move so he loses. But if cnt >=2 Then tutu can simple divide the piles in 2 parts. Example: cnt = 3, k = 6 So, 1 1 1 0 0 0. So an optimal move would be 1 0 0 0 0 0 so later second player cannot make a move. This is the same for all other cases. What's wrong?
1 0 0 0 0 0 is a victory for the first player, who removes the single stone. Note that the piles with 0 stones still count, so the move is valid (he is not choosing all piles).