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

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

We will hold HUAWEI Programming Contest 2024(AtCoder Beginner Contest 342).

We are looking forward to your participation!

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

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

Lovely score distribution ever

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

Excited!

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

A round with prizes,NICE.

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

HUAWEI Round. Excited.

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

tourist register and he will get more money

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

omg HUAWEI round

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

omg this is the first time that I see a video in the contest description!

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

yeah!

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

HUAWEI's contest!!!

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

excited

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

OH,I'm newbie, I can't do C

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

F<<<E!!!

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

    Really? I felt like E was just "yeah this is your standard ABC dijkstra problem, enjoy implementing for 10-15 mins :)" while F actually required some rough thinking.

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

      I observed that, but what's next?

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

        start with n-1 storing val-c in priority queue to next node where val=current node max value.

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

    How did you do for F ?

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

    Any ideas why this solution to E :: Last Train fails just a single test case?

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

I think D was two pointer problem.Am i right?

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

G is easier that D :)

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

For F: I was able to find out the probability of achieving $$$x = x_0$$$ and the winning probability when $$$x = x_0$$$. Using this info, how do I determine the answer.

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

Can anyone provide me edge case for my solution for Problem D Link

Approach: Precompute all the squares till 2e5 and check by dividing that if good pair exists or not.

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

Can someone explain F?

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

    First compute the probability that dealer gets at least $$$x$$$ points linearly. Then do dynamic programming over $$$dp[x]$$$ = probability that you win if you start with $$$x$$$ points.

    https://atcoder.jp/contests/abc342/submissions/50612581

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

    For the dealer we can simulate the probabilities of them having a particular sum at the end since they have a fixed move for a given sum.

    Pseudocode

    Now for the player, if we stop at a specific score $$$x$$$, we know the probability of winning is $$$\text{player_probability[x]} = 1 - \sum_{i = x}^{n}{\text{dealer_probability[i]}}$$$. However, we can also decide to continue playing, in which case it becomes the average probability among all possible dice rolls, i.e, $$$\frac{\sum_{i = x + 1}^{\text{min(x + d, n)}}{\text{player_probability[i]}}}{d}$$$, so we take the max of these two values. Doing this in decreasing order of $$$x$$$ gives us a way to calculate the probability for all scores.

    Pseudocode

    Then player_probability[0] is the value you want. To speed this up from $$$O(n ^ 2)$$$ to $$$O(n)$$$, use difference arrays and prefix sums to get rid of the inner loops in both of the above parts.

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

      Thank you,this explanation is beautiful.

      I think $$$\sum_{i = x+1}^{min(x+d,n)}\frac{player_pprobability[i]}{n}$$$ should be replaced by $$$\sum_{i = x+1}^{min(x+d,n)}\frac{player_pprobability[i]}{d}$$$ .

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

How are the rating updates for the ABC calculated if there are so many participants whose ratings are outside the rated range? I mean, they are still considered in the ranking list, aren't they? Wouldn't it be unfair to calculate the rating changes based on the rank each time, as sometimes there are stronger competitors?

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

Is it just me who overcomplicated the solution of problem C with small-to-large merging xD? Submission

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

90% of E is figuring out what the statement is trying to say 🤡

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

    I couldn't even understand statement of $$$B$$$

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

      Given sequence $$$a_n$$$ and suppose $$$b_{a_i}=i$$$. In each query given $$$x,y$$$, print $$$x$$$ if $$$b_x>b_y$$$, or $$$y$$$ if not.

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

G much easier than F, although I cannot figure it out.

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

    Tl;dr — Simple range addition, point query segtree except t[v] is a multiset of possible values and you take the max of all of the sets.

    Let each node contain a multiset of possible values for the range. Initially this is $$$a_i$$$ for a leaf node and nothing for all other nodes.

    When we perform a lazy update for the range $$$[l, r]$$$, we will add this to the set of each of the terminal nodes ($$$l = tl$$$ and $$$r = tr$$$) we reach.

    Now every node in the range $$$[l, r]$$$ is covered by at least one of these nodes, so for each query we can just walk over all the nodes which cover the position and take the max of all the values.

    Note that cancellations are now just update operations but with "erase 1 occurrence of x" instead of "insert 1 occurrence of x".

    Code

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

      And what should be the total complexity of your solution, looking from far seems like quite larger than n*(logn)^2, considering the heavy operation of transferring the laziness when required

      • »
        »
        »
        »
        3 месяца назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится
        1. We update at most $$$\log(n)$$$ nodes in a single update. In each node we add at most 1 value into a set. So each update takes at most $$$O(\log^2(n))$$$ time.

        2. We don't need to propagate the "max" update values down down since we just check the $$$\log(n)$$$ containing nodes for the given position during the query. Since we're just checking the first (greatest) element, this takes $$$O(\log(n))$$$ time per query.

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

          Oh Thank you.

          I understood now, it's kind of strange segtree where the root node doesn't necessarily contain the values related to children,

          So we don't need to push because we are not even necessarily getting down to the leaf node because terminal nodes already contain such information

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

https://atcoder.jp/contests/abc342/submissions/50599311

can anyone tell me what is wrong in this code? Any help would be appreciated

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

    Consider this input:

    Input

    Your code gives dtcovvr as output. However, d is supposed to be replaced by v. Why do we still see d in the output?

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

HUAWEI Round. Excited.

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

didn't know that discussion panel in atcoder redirects to codeforces lol

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

btw in D if we factorize all numbers, we will know if the product of two num is squared, if only after adding their factors there is even numbers of factors right? 3 -> 3 and 12 -> 2,2,3 so 2,2,3,3

but how we can find all such pairs?

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

    You can find square-free part of number (make sure to handle zeros separately). In particular, the square-free parts of both numbers must be equal. Or, you can do something similar to what is done in 1225D - Power Products, where you ignore zeros, and check the rest (there are only $$$\mathcal{O}(\log 10^5)$$$ prime factors for each number).

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

Can anyone explain me line no. 35 of jiangly's solution to problem E?

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

    the main idea is: 1. build the graph from end to begin(not from begin to end) 2. using Dijkstra

    the code he used is C++20, a little smooth.

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

To help you build intuition for F and lead you to the solution in a more natural manner, I've created an easy version $$$O(n^3)$$$ and $$$O(n^2)$$$ which focuses on the probability + DP part (instead of optimization). It also asks you to print each intermediate DP values, since debugging probability problems can be tricky. I also added some followup problems to test your understanding.

You can find the contest here: https://codeforces.com/group/7Dn3ObOpau/contest/506759

The problems are untested. If you see any issues, please let me know.

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

difficulty: G < E < F

I solved ABCDG(

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

Admin please conduct contests on both Saturday and Sunday

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

The solution to G https://atcoder.jp/contests/abc342/submissions/50593706 is hacked by:
1
1
4
1 1 1 2
1 1 1 2
2 1
3 1

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

when the prize will be awarded :)