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

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

We invite you to participate in CodeChef’s February Cook-Off, this Monday, 21st February, rated for all.

Time: 8 PM — 10:30 PM IST

Joining me on the problem setting panel are:

The video editorials of the problems will be available on our YouTube channel as soon as the contest ends. Subscribe to get notifications about our new editorials.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Hope to see you participating. Good Luck!

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

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

Excited(because plagiarism checker is back and has spoiled many cheater's profile)^-^

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

why t <= 3e5 in D ? I got 2 unnecessary TLE.

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

How to solve div2 D ??...

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

    Compute initial cost for the graph, by visiting vertices in non — decreasing order of A[i]. Call it C.

    For each '+' query, C = C + 2

    For each '-' query, C = C — 2

    For each '?' query, print(C)

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

    Actually the answer is simply $$$\sum_{i = 1}^n {A_i} - N(N - 1) / 2 + 2 M$$$

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

Why so many constructive problem in Div2.

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

Is codechef prize still distributed?

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

When will the remaining editorials be out ? . How to solve Slingshot problem (D1 E) ?

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

Tests in Tangling Tree seems to be weak. I've submitted small to large by merging large to small (which is essentially $$$O(n^2)$$$), but it still works in 0.11 code

UPD: here is the test generator

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

    Hi. Apologies for the weak test — I did check it against a solution that merge to any set (which is effectively your large to small) and realised it will pass, but it was quite late (it was prepared in a rush) and didn’t find a construction quickly so I left it.

    I figured it would not be so bad since no one who are able to code the whole thing would forget something like small to large. I was only very concerned about solutions that rebuild the whole set, since that enables a solution that does not implement reverse operation to pass.

    Anyways, I will investigate adding this test.

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

      You are absolutely right, for me the toughest part was actually maintaining $$$O(1)$$$ reverse (I had a bug in idea too, but still).

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

In my humble opinion Codechef should reward atleast the top 50 Indian coders with something. These contests' previous prize structure was very very motivating for many emerging coders from India. Sad that it's changed now. Anyways, we can't question them obviously , it's their decision to make ..

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

When can we expect editorials for the remaining problems? (particularly D1E)

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

    Slingshot solution: $$$O((nm)^2)$$$ dp would be to process cells in decreasing order: $$$dp_{i, j} = max_{(i', j')| A_{i', j'}>A_{i, j}, |i'-i|+|j-j'|>S} A_{i,j}+dp_{i',j'}$$$. We can speed up the transition to $$$O(log(n))$$$ by using a segment tree (supporting range max + point update) for each diagonal (4n-2 total), and updating dp values there accordingly.

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

      Can you please elaborate a bit? Thanks

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

        Sure! So the set of cells that are >S manhattan distance away from a cell forms a diamond. In the dp, we need to take a max of dp values of cells that are NOT in this diamond. This can be split in to 4 regions of contiguous diagonals (one from each corner).

        Picture

        Actually there are 2 types of diagonals, one indexed by $$$x+y$$$, other by $$$x-y$$$. The $$$x-y$$$ diagonals are parallel to the orange and blue lines; and $$$x+y$$$ to the purple and green.

        Process cells in decreasing order of A. Let $$$dpsum[d]$$$ be the maximum dp value over processed cells $$$(x,y)$$$ with $$$x+y=d$$$. Let $$$dpdif[d]$$$ be the maximum dp value over processed cells $$$(x,y)$$$ with $$$x-y=d$$$. The answer for cell (x,y) is

        $$$A_{x,y}+max ( max_{d<x+y-S \ or\ d>x+y+S} \ dpsum[d], max_{d<x-y-S \ or\ d>x-y+S} \ dpdif[d]) $$$

        When we get the answer for $$$(x,y)$$$ we set $$$dpsum[x+y]$$$ to $$$max(dpsum[x+y], ans)$$$ and update $$$dpdif$$$ similarly.

        We can compute these suffix/prefix maximums and update the dp in $$$O(log(n))$$$ with a segtree.

        Code: https://www.codechef.com/viewsolution/58784071

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

          Thanks a lot! That's a great explanation. I couldn't find a way to query the remaining region.

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

rating update when??why so late?

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

why not ratting updated yet?

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

The ratings have been updated for all. For users who were affected by the issue in PREFPERM, and who would have had their ratings decrease, we have made the contest unrated for them (ie. +0 rating change). There were 286 such users across all divisions.

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

    Thanks CodeChef_admin for this considerate decision. I spent almost an hour in trying to fix the solution for that problem, and I did not consider at all the likelihood that the reason for getting WA from the automatic judge would be an issue in the problem checker.