With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?
Name |
---|
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).