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

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

Hello Codeforces!

The Southern and Volga Russian Regional Contest was held in Saratov State University on 22nd of November. This contest was used to qualify the teams from Southern Russia and Volga region to the Northern Eurasia Finals.

On Nov/27/2022 13:35 (Moscow time), we will conduct the online mirror of this contest. It will last for 5 hours and is best suited for teams of three people, although it is not forbidden to participate in teams of smaller/larger size. The mirror will use ICPC rules, the same as the offline contest.

I would like to express my gratitude to all other jury members: awoo, Neon, vovuh, adedalic, DmitryKlenov, dmitryme, DStepanenko, elena and kuviman. Also, big thanks to the contest testers: IlyaLos, Oleg_Smirnov, ashmelev, pashka, and especially MikeMirzayanov not only for testing the problems, but also for his excellent Polygon system, without which it would be almost impossible to prepare the competition.

As a chief judge of the contest, I hope you enjoy the problems!

Of course, the contest will be unrated.

upd: The editorial can be found here.

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

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

Would the Southern and Volga Russia regional consider uploading test data for this year's (and also previous years') contests? The regional page is missing a lot of details.

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

    Unfortunately, I don't have any access to editing that page. I will try to find out who I should contact to upload that information for the current Regional and the 2021-2022 one (I wasn't the chief judge during the earlier seasons, so I also need to consult with the previous chief judge).

    As a temporary solution, I can upload the editorials and the tests as the contest files after we conduct the mirror.

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

Is $$$\mathcal{\color{red}{Hack}}$$$ available?

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

How challenging are the problems? Should I attempt to participate if I'm green?

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

    You definitely should

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

    For a lone green participant, the problemset can be very challenging. I advise you to play this contest with a team.

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

      What about a lone blue one?

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

        Much more suitable than for a lone green one, but there will be several problems which are not expected to be solved by anyone who is in the second division.

        The problems are very different in terms of difficulty, you will surely find several ones to solve.

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

excited

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

As a tester, I think that this is a really good set of problems. It will be of interest to a wide range of participants.

I'll add more. That, as a former chef judge, I highly appreciate the problems and think that the guys did a great job. Kudos!

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

It would be nice to finally fix language selector issue and remove excessive use of flags.

Sources with supporting arguments:

Codeforces Language Picker -- chrome extension to see how fixed codeforces language picker would look like.

Please support the initiative and stop reinforcing poor UX practices.

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

Is this contes rated?

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

Interesting provlems. Thx

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

What is test 72 of problem I?

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

How to solve problem A ?

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

    Just https://e-maxx.ru/algo/path_cover (in Russian).

    Docs form a DAG. Duplicate the vertices, for each edge of DAG add the edge (i, j+n) to a new bipartite graph. Find the maximal matching. Edges chosen for matching form a path cover. Each path is then solved independently, and it is easy.

    Bad problem: it is not easy but at the same time it is just a copypaste from e-maxx.

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

      How do you deal with duplicate vertices? I was able to figure out the DAG part and then googled my way into the mcbm solution, but I am currently unable to solve when some documents have the same permissions.

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

        If two vertices are absolutely identical (the columns in the input are equal), just remember that one of them is the clone of the other and drop it from the rest of the solution except printing answer.

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

          hmmm that's what I did initially, guess it must be something else that's wrong lol. thanks

          EDIT: Ok i think my problem was decomposing the graph improperly (if $$$(i,j)$$$ is an edge and $$$(j,k)$$$ also an edge, I removed $$$(j,k)$$$ from the graph). :facepalm:

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

          There's an interesting way to handle identical documents (credit to ashmelev): use the document index as the tiebreaker. The method you described works just fine, but this one is a bit more elegant in terms of code.

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

What is the idea for solution problem D?

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

When will the editorial be published?

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

How to see the failed test cases ? I am not able to see it

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

How to solve problem K ?

  • »
    »
    17 месяцев назад, # ^ |
    Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится
    Hint 1
    Hint 2
    Hint 3 (+ Answer)
    Solution Code
  • »
    »
    17 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Only one type of shifting is available and dp.

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

how can i hack a solution when i can't see the author's code ?

update : problem solved!

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

How to solve Problem N?

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

    First, you have to minimize the number that will appear in the first position of the answer, using as few operations as possible. If you have more operations left, do it again with the second position. Repeat the same process until you run out of operations. I implemented it storing in 10 vectors all the positions of the numbers from 0 to 9, then performing binary search in each position. Be careful with the leading zeros, and also, at the end of the process you might still have operations, if there is no way of making the firsts positions smaller. Example: "1111111111..." Then you can just delete random digits that are still not deleted.

    Hope my explanation was not terrible.

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

      Now I kinda get the concept, though the implementation seems quite complex. I wonder how so many teams solved it.

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

        It's not that complex, but there must be simpler solutions.

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

        If you have to delete $$$k$$$ values then you have to keep $$$n-k$$$ values. Let's try to understand an approach to decide the first digit (leftmost) of the answer. It cannot be a $$$0$$$ and it has to be a value in the range $$$[0,k]$$$ (inclusive). Because if we were to take the $$$k+1th$$$ value then we won't be able to take $$$n-k$$$ values in total. Greedily we choose the smallest value in the range $$$[0,k]$$$ as our first value. Mark this index as $$$l$$$, now to choose our next value we apply a similar technique but we have to choose the least value in the range $$$[l+1,k+1]]$$$. Call this value $$$mn$$$ and update $$$l$$$ to the first occurence of $$$mn$$$ in the range $$$[l+1,k+1]$$$. We can do this naively since our $$$l$$$ pointer moves atmost $$$n$$$ times in total. Now do this approach again by finding minimum of the range $$$[l+1,k+2]$$$ and so on.

        To compute the minimum of the range, I just used a segtree. This makes the implementation quite easy imo — Submission

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

What was the order of problems in the onsite contest? Will you add ghosts?

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

    The order of the problems from the official competition was the following one:

    Spoiler

    I don't know how to add ghost participants, but I'll try to find it out and, if possible, add them.

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

About Problem J :

Spoiler
  • »
    »
    17 месяцев назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится
    Spoiler
  • »
    »
    17 месяцев назад, # ^ |
      Проголосовать: нравится +22 Проголосовать: не нравится
    Another spoiler, now about problem C
    • »
      »
      »
      17 месяцев назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится
      Spoiler for C
      • »
        »
        »
        »
        17 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        can you tell a bit more about the solution? i thought keeping the count distribution of the k cards is not enough because the selection algorithm may make the states heavily biased. it may not b the case that the remaining cards are uniformly distributed before the k cards.

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

          We just used linearity of expectation. Note that the contribution only depends on the distribution of the cards. For that you only need a multinomial distribution. For every possible size of your look-back, you can compute the distribution in $$$O(n^3)$$$, leading to an $$$O(n^4)$$$ solution.

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

How do you solve H?

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

    Use a topological sort to find the minimal $$$p_i$$$ for each vertex (basically you want to ensure that $$$p_i \leq p_j$$$ if $$$i$$$ is an ancestor of $$$j$$$). Then for each vertex, you must place all ancestors before it, so just retrieve the ancestors then binary search on the leftmost position you can place it at.

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

How to solve H?

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

I'm kinda surprised so few participants solved L and G. They were much more popular on the official contest (all teams which solved 9 problems had G+H+L+6 easiest problems), and neither L nor G is especially hard.

On the other hand, A and F were the opposite of that: not solved on the onsite, popular during the mirror. Problem A is understandable, much more participants know the required techniques and can reduce the problem to those techniques; but F was considered one of the hardest problems in the set by me.

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

    When will the editorial be published?

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

    I think F is not difficult to solve it ,but maybe hard to prove it. I solved it by guessing.

    It is easy to find that we need to use DP to solve this problem in O(n^2). And then we guess dp[i]=min(dp[j]+f(j,i)) [1<=j<=i-1], try a try, ac is ok.

    If n<=300 the problem will be more difficult,I think.

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

      Proved by geometry, It actually relates to area below segments.

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

      Just upsolved it. Nothing hard, easier than A and L for sure. There was too much stress during the contest, but now it's much better.

      The problem is, in short: you can buy some points and in the end you gain the area under the top part of their convex hull.

      Solution of F
»
17 месяцев назад, # |
Rev. 3   Проголосовать: нравится +3 Проголосовать: не нравится

How solving problem E please ? I know this the problem solve math but how ?

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

J is absolutely beautiful. F and G are nice. Cool contest!

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

How to Solve L ?

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

Does anyone know what causes the verdict of hack showing "Unexpected verdict"?

I tried to hack some solutions (which seem to have wrong time complexity) for problem L, but I only got "Unexpected verdict".

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

    The "Unexpected Verdict" happens when the checker returns _fail, and is supposed to happen when a jury solution happens to fail on a valid testcase or a solution finds a better solution than the jury solution. I don't understand why this happens on problem L though, isn't the answer supposed to be deterministic (i.e. there is only one answer for one input)?

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

      Hmmmm, could it be that jury solution neither fits in TL? xd

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

        Polygon will check all the solutions marked as "Correct", and if one of them fails, will return _fail. Authors sometimes add participants solutions, so maybe one of them is slow, or maybe one of jury solutions is slow, which also can happen. Or the model solution is slow :)

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

          Yes, this time our solution (me + pashka) was actually slow. Thanks, YaoBIG. Now tests are better!

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

            Thanks for the fix!

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

            Would be also good to mark uphacked submissions in the standings (maybe change the color of '+'), and to run all contest submissions on new tests to see if they should be marked as uphacked.

            Now someone looking for the code can check top-2 team's solution for L, but it's wrong. Our contest submission is also wrong but as it's not uphacked it may seem it's correct.

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

          Ah I see. I did not know that all solutions marked as "Correct" will be checked and it is good for me to learn this! Thanks for the explanation!

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

How to solve problem H?

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

How to solve G?

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

      Thanks. I now know how to do. Additionally, can I ask when the editorial will be posted?

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

        Hopefully we'll finalize it in about 24 hours. I am sorry for the delay.

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

Nevermind... You don't have to use all contracts...

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

Solution

This is the solution of Torus path (K) . Please help me i am not able to clear all test cases , i have tried with dp.

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

    K is simpler than DP.

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

    You calculate dp in DFS order, it doesn't always find maximum path. Sometimes you can get better value if you go to already visited cell. Example:

    3

    2 2 2

    2 2 2

    1 2 2

    This problem can be solved with dp using the fact that it's impossible to use both vertical and horizontal teleports. If you don't use vertical teleports, you can calculate DP in vertical order and vice versa.

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

      But we cannot visit the same cell twice. It will be great if you can give code please

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

        We cannot visit the same cell twice but your function can visit some cells in one path and block some other paths. For the same reason we can't use DFS for finding shortest paths.

        Solution with vertical and horizontal DP: 183454259

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

          I understood that it's possible to use both types of teleports so this idea is incorrect. But in this problem you don't need it so this solution works.

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

I recognize that for D it is simply to permute $$$a$$$ such that the least pairs $$$(a_i, a_{i+1})$$$ add to over $$$m$$$. To do this I use a simple greedy algorithm: for $$$a_x$$$ starting from smallest $$$a_x$$$, pair it with largest $$$a_y$$$ such that $$$a_x + a_y \leq m$$$. Then arrange pairs as such: $$$a_{y_1}, a_{x_1}, a_{y_2}, a_{x_2}, ...$$$. The remaining elements will always cause pairs that add to $$$\geq m$$$. I came up with this algorithm through intuition (it works). Is can somebody prove correctness?

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

Where can I find the editorial?

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

How to solve problem F ?

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

Not sure why does this solution work? 187063817 (why does this solution doesn't work without line 18: dp[i][j][t] = ans = -INF; should be just ans = -INF; from my knowledge it enters an infinite loop in this case).