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

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

We will hold AtCoder Regular Contest 123.

The point values will be 300-400-600-700-700-1000.

We are looking forward to your participation!

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

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

Hope for a good contest!

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

Ah, It's too hard! :(

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

For the first time I solve three problems in ARC.

I'm so happy :)

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

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

How to solve C?

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

    Indeed how to solve $$$C$$$. Greedy algorithms like taking largest possible number fail. I felt it was kind of similar to yesterday's A

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

    Digit dp-esque dp worked for me

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

      colud you elaborate ?

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

        First, use the fact that the answer should be maximum 10 (or even lower couldn't bother to prove a tighter bound), and then we should think about how each of $$$a_i$$$ contributes to each digit of n. A length k number will contribute k digits of n from the first digit to the kth digit once, so instead of figuring out what the individual $$$a_i$$$ could be, we could shift our focus to how many numbers focus on a specific digit of n. Let $$$b_i$$$ denote the number of $$$a_i$$$ that contributes to the ith lowest digit. Then, it should be clear that $$$b_i$$$ is non_increasing similar to a cumulative frequency. Now, we just want to know if it is possible to create n from a sequence of $$$b_i$$$ that is where digit dp comes in. The first parameter of the dp is the current position starting from the lowest digit, and the second is $$$b_i$$$ at that position and finally, the last parameter is how much we carried over from the last digit.

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

          Amazing use of digit dp!

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

          I didn't understand why you use array f in your solution you did not update array f.

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

            I mean I did use the array to store the dp results in the line int &res = f[pos][choice][up]? Next time when you comment please read the code carefully and then comment.

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

    dp digit

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

    for a given k can we do it? if we can answer this then its easy just do k++ until we get one. It will never go too far. Now lets try to answer the first part that for a given k can we do it? Try to think of a dp state. run a loop from right to left digits one by one in n. ( i=1 to len(n)) i=1 corresponding to the rightmost digit.

    we will pass three variables after every iteration i. lowest and highest carry, and mx_k that is the maximum no. of i-1 digit numbers possible up to this point. and lowest and highest carry should correspond to mx_k.

    tough to explain the mx_k part. Give a good read and think you will get what I meant to say.

    my solution

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

    Another solution with dfs: The restriction that no digit can be 0 is troublesome, so I considered to clear out this. We minus n with numbers like 111111, 1111 first, and then the digits can be 0,1,2, which is a greedy problem similar to 1530A. Thus it can be proved that the answer is not greater than 5, and we are able to solve it by dfs. For each number, we only need to fix its length, and minus n with 11..1 with the same length. In the end check whether n (after minus) can be constructed by numbers which digits are 0 or 1 or 2. With a little amount of optimization, the solution was accepted.

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

how to solve D? there's no editorial for it

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

    If $$$a_i > a_{i+1}$$$, it's optimal to choose $$$b_i = b_{i+1}$$$, else it's optimal to choose $$$c_i = c_{i+1}$$$.
    Then, the $$$b_i$$$ and the $$$c_i$$$ can be uniquely determined for a fixed $$$b_1$$$ and they have the form $$$\mid b_1 - k \mid$$$ ($$$k$$$ is different for each $$$b_i$$$ and $$$c_i$$$).
    The optimal $$$b_1$$$ is the median of the $$$2n$$$ values of $$$k$$$.

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

    ternary search on the value of $$$B_1$$$, knowing that $$$B_i=B_{i-1}+max(A_i-A_{i-1},0)$$$ and C as the complement of B

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

      Can you share your submission? My ternary search fails for some reason. Submission

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

        I think you make an overflow in Calc, sum can be up to 1e15*2e5 which is to big

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

          Thanks. The actual bug was that minimum sum can be over 1e18. So I have to take initial value as LLONG_MAX. Also as you pointed out in the ternary search, 1e15 will overflow. So taking low as -1e13 and high as 1e13 now worked for me. Even 1e12 is bad.

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

    It's the first editorial in E. Seem like the author put it in the wrong place.

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

    One of the (almost) middle elements can be 0

    After fix we do simple greedy to left and right

    arc123/submissions/24365978

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

Err......Starting from C, the problems are too hard for me:(

I have to say, contests in AtCoder are becoming more and more challanging. Is that because the problem setters are stronger and stronger or I'm weaker and weaker?

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

    I think AtCoder is turning harder and harder.

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

    All the latest ARCs are mostly hard, you also need to get used to the ARC problems, on my first ARCs I always had a bad performance and the problems seem quite difficult, however after some contests, you will find the problems more accessible (excluding all F's, and some E's, and the other problems are still hard, but at least you can elaborate more on how to solve them). They are really fun and you can learn and enjoy a lot. I am really grateful to all atcoder writers, coordinators, and staff, the contests are great.

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

Why number of contestant is so small than number of contestant at any begginer contest !!

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

How large could the answer be for problem D? I thought the answer could go up to $$$10^{18}$$$ which was a terrible mistake as I got 7 WA because of it and changing the limit to LLONG_MAX just solved the issue.

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

For A the approach I followed is,

Let mean of consecutive differences in the array be dd;

So I iterated on differences from (dd — epsilon) to (dd + epsilon) (epsilon can be anything I considered 2) and checked all possible arrays for a particular difference and took the array with minimum operations. It got accepted but I cannot prove it.

Can anyone help me with the proof?

Here's my submission Task A

Thanks in advance :)

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

How to solve B?

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

    First sort all the three input arrays(A,B,C) and then count for valid triplets such that the upper bound of first element from the first array A uniquely exists in second array B and upper bound of that element from second array B uniquely exists in third array C.

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

      thanks nice explanation :)

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

        It's surely TLE.How can you expect erase function to work in $$$log(n)$$$ complexity. I used ordered set to erase the elements whose complexity is $$$log(n)$$$ unlike vectors.

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

          I mean all self-balancing binary search trees, such as the std::(multi)set (red-black tree) or avl trees, allow deletion in $$$O(log(n))$$$ complexity due to its self balancing nature. For this specific problem, I used std::multiset which worked under 150ms.

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

Thanks a lot for a detailed editorial like this.

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

Will you provide the code for F?

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

In Problem C Can Anyone Explain

  • A number can be written as the sum of K good numbers if and only if it can be written as the sum of the following:
  1. An integer between K and 3K;
  2. The sum of at most K good numbers, multiplied by 10.

The above statement in Editorial. It would be a Great Help