Блог пользователя spookywooky

Автор spookywooky, история, 3 года назад, По-английски

Apparently there is no official announcement, so I hijack this. Ask questions here.

  • Проголосовать: нравится
  • +41
  • Проголосовать: не нравится

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

F Editorial says S(p) is the LCM of the loop lengths. Why this?

I would expect that it is the max loop length.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    For something like 2 3 1 5 4 the max loop from the first 3 is 3, but if you simulate it through 3 iterations, the first 3 are ok but the last 2 are in the 'odd' phase of their 2-cycle.

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

    Consider $$$P = (2, 3, 1, 5, 4)$$$. The ball wills move like this:

    • 2, 3, 1, 5, 4
    • 3, 1, 2, 4, 5
    • 1, 2, 3, 5, 4

    After Snuke shouts three times, Person 4 has Ball 5, so 3 (the maximum loop length) is not an appropriate answer.

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Each time Snuke screams, every Person i such that $$$i \neq p_i$$$ gives their ball to Person $$$p_i$$$ simultaneously.

      Doesn't that mean, that after the first exchange, $$$4th$$$ and $$$5th$$$ men have to stop exchanging? That's misunderstanding in statement. I counted max loop lengthes.

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится +1 Проголосовать: не нравится

        $$$p_i$$$ don't change after people pass balls. They are elements of a fixed permutation $$$P$$$.

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        I mixed that up, too. But I think the statement is clear. Especially allways all persons give their ball to p[i]. It is just that i!=p[i], because if i==p[i] that ball would never move at all.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Can anyone please explain the formula given in the editorial for getting the count of each partitions ? It would be of great help.

    • »
      »
      »
      3 года назад, # ^ |
      Rev. 3   Проголосовать: нравится +3 Проголосовать: не нравится

      Consider counting the number of permutations of such $$$(1, \ldots, N)$$$ that it consist of $$$k_1, \ldots, k_m$$$ cyclic permutations. These consist of two factors:

      What "cyclic permutation group" does each element belong?

      This is equivalent to determining such sequence $$$a_1, a_2, \ldots, a_n$$$ such that:

      • Each element $$$a_i$$$ is an integer between $$$0$$$ and $$$m$$$;
      • For each $$$j = 1, \ldots, m$$$, there are exactly $$$k_j$$$ elements such that $$$a_i = j$$$.

      So this means that element $$$i$$$ belongs a cyclic permutation group $$$a_i$$$, or does not belong to any cyclic permutation if $$$a_i = 0$$$.

      How many such sequences are there? Consider a sequence B = (($$$N - \sum k_j$$$ copies of $$$0$$$), ($$$k_1$$$ copies of $$$1$$$), ($$$k_2$$$ copies of $$$2$$$), $$$\ldots$$$, ($$$k_m$$$ copies of $$$m$$$)). This is an $$$n$$$-element sequence, and each permutation of $$$B$$$ correspond to the aforementioned $$$(a_i)$$$ one-to-one. Therefore, the number can be found as:

      $$$\displaystyle \frac{N!}{\prod_j k_j!}.$$$

      What does each cyclic permutation look like?

      Given a set of elements that forms a cyclic permutation, we have to determine the actual permutation. For simplicity, we consider a cyclic permutation of $$$\lbrace 1, 2, \ldots, Q \rbrace$$$, of length $$$Q$$$.

      What should $$$1$$$ map to? It should not map to $$$1$$$ itself, since it will never result in a cyclic permutation of length $$$Q$$$. Therefore there are $$$Q-1$$$ choices. Say $$$1$$$ maps to $$$p_1 \neq 1$$$. What should $$$p_1$$$ map to? It should not map to $$$1$$$, because it becomes a cyclic group of length $$$2$$$; nor should it map to $$$p_1$$$ itself. So there are $$$Q-2$$$ choices. The next element has $$$Q-3$$$ choices for its next mapping direction, the next has $$$Q-4$$$, ... and so on, before determine the destination of the last element, which should now go back to $$$1$$$ (no other option).

      Therefore, there are $$$(Q-1)!$$$ options.

      But wait, there's more!

      To sum up the last two sections, we obtain the following number:

      $$$\displaystyle \frac{N!}{\prod_j k_j!} \cdot \prod_j (k_j - 1)!.$$$

      However, in the first chapter we distinguished the cyclic group with the same length. So we have to divide by an additional duplicate-remover.

      To do this, let's convert the sequence $$$k_1, \ldots, k_m$$$ into the sequence of occurrences: $$$F_1$$$ elements of $$$k_1, \ldots, k_m$$$ are equal to $$$K_1$$$, $$$F_2$$$ elements are equal to $$$K_2$$$, and so on. Using this notation, the last expression can be re-written as follows:

      $$$\displaystyle \frac{N!}{\prod_{F_a, K_a} (K_a!)^{F_a}} \cdot \prod_{F_a, K_a} ((K_a - 1)!)^{F_a}.$$$

      Now we can divide by the freedom of permutation of same-length cycles:

      $$$\displaystyle \frac{N!}{\prod_{F_a, K_a} (K_a!)^{F_a}} \cdot \prod_{F_a, K_a} \frac{((K_a - 1)!)^{F_a}}{F_a!}.$$$

      This is equivalent to the expression in the editorial.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    If you know some group theory, you will notice that $$$S(p)$$$ is the "order" of the permutation. If you google this term, you'll probably find a proof for why $$$S(p)$$$ is the LCM of the lengths of the disjoint cycles (what you call loop lengths).

»
3 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

Great.Someone explain me the reason of the solution in the editorial of problem E.Why same number of edges and nodes guarantee that there are exactly two possible ways of directing a particular connected component?

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +14 Проголосовать: не нравится

    The editorial seems to be updated.

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +20 Проголосовать: не нравится

    A Connected graph with 'n' nodes and 'n' edges will definitely have a simple cycle. You can think of it as a ring graph.

    Since it is a directed graph, their are 2 ways — clockwise and counter-clockwise.

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

    The last sample is what helped things click for me. It showed a disconnected case, but 2 different arrangements that worked... started with asking if the connected parts had to have a cycle (yes), and then testing what happened with variations based on the part that had a 3-cycle with a vert-and-edge pointing into it. Not a proof, and still had to whip up the brute force sim, but was enough to convince myself... edit: also helped to narrow down range of ok e vs. v relationships, testing out (eliminating) various other graphs like hourglass, 7-segment digital display, flow thingies (start, n mids, end), etc...

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится +9 Проголосовать: не нравится

      I used a different approach instead of e == v relationship. I started from leaf nodes and removed all the leaf nodes sequentially. After this, all the remaining nodes in the graph must have a degree of 2.

      Somewhat inspired from this of a recent Div 3 contest.

»
3 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Can someone help me with [D].I can't understand how for case-> 3 (5,2),(7,2),(10,2) the answer is coming as 2 (https://atcoder.jp/contests/abc226/tasks/abc226_d)

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In B I made a vector of strings,sorted them and calculated the answer.It gave WA and TLE on some tc.But when I made a vector of vectors, sorted them and then calculated the answer, it gave AC. Can someone plz explain this?

WA->(https://atcoder.jp/contests/abc226/submissions/27120194)

AC->(https://atcoder.jp/contests/abc226/submissions/27119995)

»
3 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

An "User Editorial" has been provided for problem F. Can someone explain how we are able to iterate through all possible LCMs without TLE?

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Let's fix N = 50, and we want to estimate what the maximum LCM could be. This is equivalent to, if we partition N to be $$$N = a_{1} + a_{2} + ... + a_{m}$$$,the LCM would be $$$LCM = lcm(a_{1}, a_{2}, ..., a_{m})$$$. Apparently we should make every $$$a_{i}$$$ to be coprime with others, to avoid loss of LCM. So an optimal solution to this would be: $$$a_{1} = 1, a_{2} = 4, a_{3} = 5, a_{4} = 7, a_{5} = 9, a_{6} = 11, a_{7} = 13, LCM = 180180$$$. 180180 is a loose upper bound, considered that some numbers in [1, 180180] won't be a valid LCM(some large prime, etc.). Actually for N=50, there are only 1056 valid LCM. So enumerating all possible LCMs would be easily fit in the time limit.