Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

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

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

We will hold UNIQUE VISION Programming Contest 2022 Winter(AtCoder Beginner Contest 283).

The point values will be 100-200-300-400-500-500-600-600. We are looking forward to your participation!

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

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

UNIQUE VISION rounds can always surprise me.

Looking forward to the contest in the evening!

Merry Christmas!

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

How to do problem E?

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

    Try to use dp.

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

      Will iterative dp work for this problem ? If yes, then please share the solution (anyone who solved).

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

        Try d[i][conf] = minimum number of steps to consider the first $$$i$$$ lines. (i.e. solve the first $$$i-1$$$ lines) $$$conf \in { 0, 1, 2, 3 }$$$ shows if lines $$$i-1$$$, $$$i$$$ have been flipped in this particular configuration.

        When calculating d[i][..], you are "cementing" the state of line $$$i-1$$$.

        Build d[i][conf] from d[i][conn], where $$$conn$$$ has the same configuration as $$$conf$$$ for line $$$i-1$$$, but anything for line $$$i-2$$$.

        Suppose d[1][0] = 0, d[1][1] = 1. Watch out, when building d[2][..] you cannot flip line 0. Also, when building d[n+1][..] you don't want to flip line n+1.

        It helps to border the matrix.

        ans = min(d[n+1][conf] | 0 <= conf < 4).

        Solution.

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

        I solved it using the following state: Let j = 0/1 where 1 means we flip the current row Let k = 0/1 where 1 means we flip the next row dp[i][j][k] = the min cost s.t. the rows i is in state j and the i+1 th row will be in state k (so the cost is not considered for the i+1th row yet).

        The rationale behind this state is that at the jth row is dependent on whether the i-1th row is flipped and whether the i+1th row must be flip, and depending whether the next row can be both flip/unflip, flip only, unflip only, we update the state.

        The ans would be min(dp[H-1][0][0], dp[H-1][1][0]).

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

In F.
I just moved $$$j$$$ backward from $$$i - 1$$$ to $$$0$$$ and did ans[i] = min(ans[i], abs(i - j) + abs(a[i] - a[j])); and broke out of inner loop when if (abs(i - j) - 1 >= ans[i]) and did similarly for $$$j$$$ from $$$i + 1$$$ to $$$n$$$.

https://atcoder.jp/contests/abc283/submissions/37510713

Is this intended?

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

    I wasn't expecting this easy solution to this problem.

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

    I have the similar solution, The test cases are so weak.

    I'm curious if this solution can be hacked?

    https://atcoder.jp/contests/abc283/submissions/37522936

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

      del

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

        why is it passing :?

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

        It is not n*n but n*sqrt(n) which should be ok. The terminating condition in inner loop uses x which is continuously getting minimized and for these type of solutions for this question we can generate tc which will give n*sqrt(n) time complexity. This solution is somewhat like mentioned here

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

          Why is the time complexity becoming O(n*sqrt(n))?

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

          It is not n*n but n*sqrt(n)

          True, good find! What's more: we can prove that

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

    I read codes from SSRS, and I think the intended solution is based on segment tree.

    To compute t=abs(pi-pj)+abs(i-j) for some i, there are several cases.

    case1: j<i, and pj<pi, then t=pi-pj+i-j=pi+i-(pj+j), so pi+i is constant and min(t) is equivalent to max(pj+j), which could be solved by a query of maximum value in the interval of [1, pi-1]. Then, we update index of pi, with value of pi+i

    case2: j<i, and pj>pi, then t=pj-pi+i-j=i-pi-(j-pj), and min(t)=max(j-pj), which could be solved by a query of maximum value in the interval of [pi+1, n]. Then, we update index of pi, with value of i-pi. for j>i, the idea is similar.

    Well, my first idea is to transform it into a geometry problem, which is related to manhattan distance, but failed getting a solution.

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

      Yep, this is what I did. I think this is the intended solution.

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

      Well could u please explain why u have to update the tree SummerSky

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

        Well, I think the solution is to compute di from i=1 to i=n. Thus, when we are computing di, we need some intermediate results from 1 to i-1, while computing d_(i+1), we would need results from 1 to i. This is done in a sequential order, and thus we have to repeat the following steps: compute di according to results of [1, i-1], then update i; compute d_(i+1) according to [1, i], and update i+1

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

    I think the worst-case scenario in your solution will go O(n*sqrt(n)), although a nlogn solution is possible but given the constraint of the problem, your solution should be acceptable.

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

can anyone please provide some tricky test case for problem E?

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

Is it rated still?

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

ACed E after contest because I mistyped = as ==, pain

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

Is it rated or not?

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

G is almost the same as problem 4 from this blog.

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

Please share the testcases of D.

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

Problem E had weak system tests. For example, my accepted solution gives wrong answer on this test:

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

My solution to D was a bit simpler than the editorial.

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

Maybe this contest is not rated anymore ? I noticed that there has been no rating update. Typically AtCoder does this shortly after a contest is over.

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

    From clarification:

    There was a constraint violation in the test case for the problem D. The number of ‘)’ is less than the number of ‘(’ in some test cases. We are currently discussing whether this contest will be rated.

    Sorry for the issue.

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

Update:

For the following 246 participants, ABC283 is Unrated. We are sorry. (This includes those who were originally Unrated.)
The others will be Rated. Please wait a little longer for the update.
Please contact us if you find anything wrong.

Unrated list: https://img.atcoder.jp/abc283/list.txt

Original tweet: https://twitter.com/atcoder/status/1606681898268655618

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

Cool contest, thanks!

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

Is it possible to solve E using 2-SAT?