With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | atcoder_official | 162 |
3 | maomao90 | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
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).