I_so_sad's blog

By I_so_sad, 10 years ago, In English

With the problem C Happy Birthday Tutu and E Risk of Trading,I can't find out any idea. Can someone help?

  • Vote: I like it
  • +6
  • Vote: I do not like it

| Write comment?
»
10 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    if(cnt==k)puts("Better luck next time!") which is not right for the second example.

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        10 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        how is that a winning move?

      • »
        »
        »
        »
        10 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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?

        • »
          »
          »
          »
          »
          10 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

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