rng_58's blog

By rng_58, history, 5 weeks ago, In English,

I couldn't find a place to discuss this.

When will we get results? Is anyone confident with B or F?

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

»
5 weeks ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

I was wondering the same :).

I think my idea of B is right, but there could always be an implementation bug (especially since the sample cases were very small; I did not stress test my solution). What I did was for each subtree compute how much beacon time from the root you need and how much beacon time you have remaining if you need to traverse this entire subtree. And then do another dfs to determine final node you are going to end up in. The have/need for the parent structure is passed as a parameter to this function and have/need for the siblings can be calculated with prefixes and suffixes from the first calculation.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +20 Vote: I do not like it

    Hm, I have the same feeling about B (idea seems right, but could have bugs), but my solution does not have any prefixes and suffixes :)

    Basically, for each vertex we compute the number of vertices a and the total power p in its subtree (we root the tree at 1). If p<a, then there's no solution. Now we look at complements: n-a and total_power-p. Let delta be n-a-(total_power-p). If delta>0, it means that the path from 1 to the final vertex must go at least delta steps towards our vertex. Now we have constraints like "the path to final vertex must go at least x steps towards vertex y", so with another dfs we can find all edges that must lie on the path to final vertex, and then we just check if they lie on one path, if yes, extend it down as much as possible, and finally check that total_power is enough for that traversal.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +43 Vote: I do not like it

      And that's exactly what happened: had a really tiny bug, more specifically that in the "if p < a, there's no solution" line above we should exclude the subtree corresponding to the root (full tree), since the root does not need to be entered. A one-line fix, and it passes in upsolving :)

      Would've been really amazing to win after not being able to solve any problem for the first hour.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +10 Vote: I do not like it

        I had exactly the same bug! In addition, I also had an overflow, but with those two fixes my solution passes in upsolving.

        Would not have meant a win for me (Gennady was just too fast for that), but for me a second place also counts as 'amazing' :).

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +10 Vote: I do not like it

        Were you really not able to solve E for first hour :P?

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +24 Vote: I do not like it

          "solve"

          Solving E in one hour is pretty tough. Good thing all of us already "solved" the exact same problem about a dozen times already.

          Seriously, what kind of problem-setting is this? "I made 5 problems and don't feel like making another one, just throw in Catalan numbers or something"

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +43 Vote: I do not like it

            Well, I find the problem nice enough for the easiest problem. I've spent a couple of minutes thinking before I got the Catalan numbers idea. It seems I'm not the only one who haven't got the idea instantly, so the problem is ok.

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +3 Vote: I do not like it

            I definitely agree, I read this problem and was like "wtf, did they just give me Catalan's number definition?" and spent more time convincing myself that there is no hidden trap here and it really is just Catalan than actually solving this problem :P. Especially after participating in dozen of Andrew Stankevich contests there shouldn't be anyone out there who doesn't know what Catalan numbers are xd. I don't know which definitions people that needed to think about it know (because Catalan's numbers have a lot), but what is described in statement is in my opinion best known one (maybe after slight change that Um_nik mentioned), so I see no point of posing that problem in a contest. At least I got a screen when I was leading, but that would be it for my today's achievements xD.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Yes. Well, I've been trying to solve D and E, since everybody was submitting them. I've briefly switched to F, implemented incorrect approach, and submitted it, but that took me probably 15 minutes or so. So the remaining ~1 hour before my first accepted run I spent on D and E, I think roughly equal — about half an hour for each. Since coding for E is trivial, all this half an hour was spent before noticing that those are Catalan numbers.

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +31 Vote: I do not like it

            I guess I did not implement the slow solution and notice the pattern because of the logic that W4yneb0t alludes to: this is Yandex.Algorithm finals, they won't give a sequence that is OEISable :)

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +10 Vote: I do not like it

            Ehm... Isn't it like the definition of Catalan numbers? Just assume that each player can take only one stone in one move but they don't have to alternate moves.

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it +46 Vote: I do not like it

              Yes, rub it in :)

              I don't know what else to say. Yes, in hindsight it's obvious. But I still spent 30 minutes before seeing it.

»
5 weeks ago, # |
  Vote: I like it +20 Vote: I do not like it

Approximately in 2 hours from now there will be an award ceremony, after that the results will be unfrozen.

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Btw, since there are also a number of people competing onsite, I think they will be announcing the results in some kind of award ceremony, which might take a while.

I also asked a question (using the messages) about when the results will become available a while a go, but haven't received an answer yet. I am afraid that whoever is answering the messages is now also busy with the award ceremony.

»
5 weeks ago, # |
  Vote: I like it +46 Vote: I do not like it

Formulas for calculating bonus penalty work awful at contests like this. I think getting -13, -6 or -0 (lol) minutes for blind submit is a joke. Maybe you should set a lower bound -20 or -40 minutes next time?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +60 Vote: I do not like it

    The choice between submitting open and blind shouldn't be obvious. Since almost everyone solved those 3 problems, you should be almost certain that your solution is correct, so you will have some incentive to submit blind even if the bonus is very low. Predicting whether a task will have -0 or -20 for a blind submission could also be considered a skill.

»
5 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it

Is there a way for non-contestants to see (and try) the problems?

»
5 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it

So, does anyone have any ideas on how to solve F? Even solutions that timed out, but are still runing in reasonable time will be welcomed.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    What is reasonable time for you? I think that obvious O(6n) can be sqeezed through TL with some hacks.

    If the dimension of linear space is big (close to n) then for each number there are few corresponding subsets and for many branches it is obvious that Bob wins because he forbade all good subsets.

    If the dimension is small then:
    1. The amount of numbers to check is not so big
    2. If Alice already has some set of numbers X then a and are essentially the same. If two numbers are the same then Alice only need one of them and she can guarantee that she will get one (after Bob take one, Alice take another). When the dimension is small we can significantly (or not) reduce search space.

    Also I have a hypothesis that in every state Alice can win for numbers in some linear space. If it is true then we can solve the problem in O(3npolynom(n)).

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +30 Vote: I do not like it

      For a faster solution, after making this observation, the problem becomes much easier:

      observation

      After making that observation, there is a straightforward O(3n * n) solution. It's possible to speed up to O(2n * poly(n)), but I didn't think it was easy to squeeze a O(6n) solution, so that's why the bounds are so low.

»
5 weeks ago, # |
  Vote: I like it +30 Vote: I do not like it

How to prove the solution of problem C? I know the solution is sort xi and add points start from largest xi. But I cannot prove it.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +50 Vote: I do not like it

    Let . Say, the input weights are sorted non-increasingly (x1 ≥ x2 ≥ ... ≥ xn). We want to show the existence of such that λ(y1, ..., yn) ≥ λ(x1, ..., xn) for . Then, λ(y1, ..., yn) is equal to the density of the subgraph containing k heaviest vertices.

    We'll take the input sequence of weights (x1, ..., xn) and transform it into (y1, ..., yn). If already some k largest elements of (xi) is equal to , we're done. In the opposite case, take two largest weights x1, xa + 1 and say that x1 = x2 = ... = xa > xa + 1 = xa + 2 = ... = xa + b > xa + b + 1 (assume xn + 1 = 0).

    Now, we want to transform (x1, ..., xn) into (x1', ..., xa + b', xa + b + 1, ..., xn) so that x1' = x2' = ... = xa' ≥ xa + 1' = xa + 2' = ... = xa + b' ≥ xa + b + 1, the sum of weights is equal to 1, at least one of the inequalities is an equality, and λ((xi')) ≥ λ((xi)). Now, the choice of x1' determines uniquely the new sequence of weights. Moreover, it's not hard to see that λ is a linear function on x1'. It means it suffices either to minimize x1' (in this case xa' becomes equal to xa + 1') or to maximize x1' (in this case xa + b' becomes equal to xa + b + 1).

    A single step increased the value of λ and reduced the number of distinct non-zero weights in the sequence. We apply this step until a single such non-zero weight is left and in this way we arrive at the sought sequence (y1, ..., yn).

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +30 Vote: I do not like it

    Somewhat more elementary proof. For simplicity consider the case n = 4. Suppose that x1 ≥ x2 ≥ x3 ≥ x4, and λ = ax2 + bx3 + cx4.

    When x1 ≥ x2 ≥ x3 ≥ x4 and x1 + x2 + x3 + x4 = 1, it is natural to replace them with non-negative p, q, r, s such that . Then,

    This is a weighted harmonic mean of {(a + b + c) / 4, (a + b) / 3, a / 2, 0}. We can find subgraphs with density {(a + b + c) / 4, (a + b) / 3, a / 2, 0} as you described.

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it +50 Vote: I do not like it

      Here is a proof which seems most natural. We would like to find a subset A such that , or equivalently |E(A)| ≥ λ |A|. Let Ap = {xi|xi ≥ p}. Then .

      Therefore we can find some p for which this quantity is nonnegative. (When Ap is empty, it contributes 0 to the sum so we can find some nonempty set.)