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 | 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 | 150 |
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).