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

Автор TripleM5da, история, 22 месяца назад, По-английски

 Hey everyone!

I'd like to invite you to participate in the JCPC 2022 contest on the gym on Jan/22/2023 13:00 (Moscow time)

The problems were created by me (Yes only me).

I'd like to thank IsaacMoris and El-Ged_Sevawy for helping me prepare the contest and also mahmoudbadawy for helping (can't remember what he did thou).

Also onsite participants might note that statements changed that's because someone I don't like changed my statements for the onsite contest so I decided to publish the original statements here.

Btw spoiler for the contest theme:

Анонс JCPC 2022
  • Проголосовать: нравится
  • +118
  • Проголосовать: не нравится

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

When will the editorial be released? If not, how to solve D, E, H, J?

  • »
    »
    22 месяца назад, # ^ |
      Проголосовать: нравится +23 Проголосовать: не нравится
    Problem D
    Problem E
    Problem H
    Problem J
    • »
      »
      »
      22 месяца назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Any idea for problem I?

      • »
        »
        »
        »
        22 месяца назад, # ^ |
          Проголосовать: нравится +11 Проголосовать: не нравится
        Really fun problem!
        • »
          »
          »
          »
          »
          22 месяца назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Any idea for problem G please

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

              but in the example we can see that - with u = 7 and v = 1, the output is "No" even though v <= maxVal, which was 10 in the initial array - with u = 6 and v = 3 the output is "Yes" since it matchs your idea

              are you sure that the idea was right or it's the first hint of the problem

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

                Sorry I got confused between u >= v and u < v, I corrected the above.

»
22 месяца назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

So how to solve C...?

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

    Get any maximum matching for the graph then remove edge(1,match[1]) and run try_khun(1) on the rest of the nodes after that remove nodes 1 and new_match[1] from the graph

    Do the same for all other i nodes from 2 to $$$N$$$.

    Complexity $$$O(N^2)$$$

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

      Isn't this $$$O(N^3)$$$? (One iteration of Kuhn is $$$O(N^2)$$$)

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

        Well yes but no, it's $$$O(N^3)$$$ per say but under given constraints it should pass easily.

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

    The problem asks for the lexicographically minimal perfect matching in a bipartite graph. Let's solve it in $$$O(N M)$$$, where $$$M$$$ is the number of edges in our graph (in our problem, $$$M = O(N^2)$$$.

    First, find any matching. Denote the corresponding mate for vertex $$$i$$$ in the left side as $$$L(i)$$$ and the corresponding mate for vertex $$$i$$$ in the right side as $$$R(i)$$$. We will iteratively adapt this matching to be lexicographically minimal.

    Let's consider vertex $$$i$$$ (in order from $$$1$$$ to $$$N$$$) and its match, $$$L(i)$$$. Let's suppose we want to match $$$i$$$ with some $$$j$$$. One correct approach would be to first unmatch $$$(i, L(i))$$$ and $$$(R(j), j)$$$, forcefully match $$$(i, j)$$$ and run one iteration of Kuhn's algorithm to match $$$R(j)$$$ without visiting $$$i$$$ in the left side; however, this would be too slow ($$$O(N^2 M)$$$), as we have to do this $$$O(N^2)$$$ times.

    However, as stated above, we can match $$$i$$$ with $$$j$$$ if and only if there is an alternating path from $$$L(i)$$$ to $$$R(j)$$$ without visiting vertices $$$1, 2, \ldots, i$$$ in the left side. Then, for a given $$$i$$$, we can run a simple DFS starting from $$$L(i)$$$ to find all reachable vertices on the right hand side via an alternating path (starting with an unmatched edge). Notice that this is done on the transpose of the original graph, as non-matching edges flow from right to left and matching edges now flow from left to right. Then, we can connect $$$i$$$ with the minimum (yet-unassigned) $$$j$$$ such that there is an edge $$$(i, j)$$$ and $$$j$$$ is marked as reachable.

    Complexity is $$$O(N M) = O(N^3)$$$.

    Can it be done faster/easier?