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

Автор peti1234, 2 года назад, По-английски

Hello Codeforces!

I am happy to invite you to Codeforces Round 783 (Div. 2), and Codeforces Round 783 (Div. 1) which will be held on, Apr/19/2022 17:35 (Moscow time)! This round is rated for both divisions.

I would like to thank the following people who made the round possible:

In each division there will be 6 problems and 2 hours to solve them.

Score distribution:

Div. 2: 500 — 500 — 750 — 1500 — 2000 — 2500.

Div. 1: 250— 1000 — 1500 — 2000 — 2750 — 3500.

Good luck!

UPD: Editorial

UPD2: Congratulations to the contest winners:

Div. 2:

  1. HenHenHenAAAAAAAAAAAAA

  2. QiangBro_ShuDe

  3. MarioPariona117

  4. Moomer

  5. SpadeA261

Div. 1:

  1. djq_cpp

  2. tourist

  3. maroonrk

  4. Um_nik

  5. Rewinding

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

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

Auto comment: topic has been updated by peti1234 (previous revision, new revision, compare).

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

As a tester, good luck and have fun!

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

Am I the only person who is surprised from low points in score distribution?

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

As a tester, good luck and have fun! Problems are interesting and well prepared.

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

GoodLuck everyone!!

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

Maybe it will be like that: A(500), B1(500), B2(750)

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

Why does it take place on Tuesday?????

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

Judging from the score distribution, it seems like a speedforces round for div 2. Hoping for +ve delta for everyone.

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

As not a tester, good luck and have fun!

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

.

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

I will participate in this contest with my favorite electronic cigarettes.

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

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

ocean of downvotes >_<

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

downvotesforces

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

Anybody here who can help me to change my username in codeforces id ??

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

People who are downvoting for no reason, may their girlfriend and wife cheat on them

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

    Jesus christ, I did not know someone takes contribution so seriously to a point where they pray on someone's downfall when they get downvoted. I get the sentiment that getting bombarded with downvotes is unfair, but I feel like you should not be that extreme when it comes to some internet points

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

      Chill bro. Its a joke

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

      OTOH consider that people who focus on dropping someone's internet points aren't gonna be super nice IRL to balance it out.

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

        Solid point, but man why can't everyone just be nice to each other :(

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

          Limited resources, both physical and abstract. Personality conflicts arising simply because we're not bots or a hivemind, but individuals. There's a balance to strike, everyone being perfectly nice would suck in other ways.

          tl;dr conflict's normal

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

thanks to ones for making this round possible

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

I'm afraid that people would be happier with 1000-1000-1500-3000-4000-5000 scoring in div2

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

Am I the only one who can't focus on solving the fourth problem just because there are too less successful submission.

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

    I see it as a opportunity to improve my problem solving skills, headbutting hard stuff mid contest.

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

Codeforces Round #783 (Div. 2) in one photo:

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

Div.1 C is weird. I dislike it very much.

It's not that I failed to solve it, but such problem should appear in MO instead of competitive programming.

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

How to solve Div2 D?

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

    I just went with two maximum segment trees, one storing $$$dp_i - i$$$ and the other just storing $$$dp_i$$$ and as you iterate through the array, update the values at the relative prefix sum order (so just coordinate compress all the prefix sums and then use the order as indices)

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

      I even did it with 3 segment trees... looking for an elegant way to solve it.

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

        I did the same 3 segment trees sorting dp[i]-i , dp[i] and dp[i]+i. Although spent like 50 minutes debugging my solution :)

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

What was the segment tree idea in D? I was thinking for any element e in the prefix sum array, we need to find the rightmost element in the suffix that is greater than prefix[e-1] in log n, but I couldn't figure out how to encode this into a data structure.

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

It is discouraging to see C was leaked like half an hour ago before the contest ended on same youtube channel that leaked answers during the last contest. It has around 350 views.

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

How to do Div.2 C? I did an $$$O(n^2)$$$ way and it was too slow.

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

    maybe you should consider what index should be "0", near the index should be "1", and ans+=a[i]/a[i+1]+1

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

    Check for each i (put that i 0 then form a decreasing sequence in the first half and an increasing sequence in the second half).

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

    My $$$O(n^2)$$$ was accepted. For each element, suppose the final value for $$$b_i$$$ is $$$k_ia_i$$$ for $$$k_i$$$ which is integer (and could be negative). Then you want

    $$$k_1a_1 < k_2 a_2 < ... < k_n a_n$$$

    Since $a_i\geq 1$, we bruteforce over the last index $$$i$$$ where $$$k_i$$$ is non positive. Set $$$k_i=0$$$. Then greedily assign $$$k_1, ..., k_{i-1}$$$ so $$$k_{i-1}a_{i-1}<k_ia_i$$$, $$$k_{i-2}a_{i-2}<k_{i-1}a_{i-1}$$$. Same thing for $$$k_{i+}, ..., k_n$$$. The choice of $$$i$$$ with the minimum $$$\sum_j k_j$$$ is the solution.

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

    the solution is in the testcases explanation, just find number of operations required when a[i] is kept 0, try for every index and output the minimum

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

    Okay, apparently, I did the same thing. For each $$$i$$$, I set $$$b_i = 0$$$, then I went through to the left and the right finding out the no. of operations to make the left decreasing and right increasing. Then, I output the minimum no. of operations. But then this $$$O(n^2)$$$ didn't work. I am using Python 3 btw. Is that why?

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

For problem $$$D$$$, I tried having a DP of $$$dp[i]=\max_{j<i} { dp[j] + sgn(PS[i]-PS[j])*(i-j) }$$$ where $$$PS$$$ is presum table and $$$sgn$$$ is the sign function. I was wondering if we can use a DP speedup (convex hull) on it, but couldn't prove monotonocity. Can I get any hints if this is an ok approach/what I am missing?

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

    Hint: use segment tree to speed up computation of your dp (maybe more than one).

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

For Division 2 The problems rating is not appropriate. First and second problem should have rating of 1000.

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

Guys i am confused https://codeforces.com/contest/1668/submission/154129473

above submission is passing pretest but

https://codeforces.com/contest/1668/submission/154104345

this doesn't. Although both are exactly same except that gans in first one is initialised to LLMAX. does answer in any test case exceed LONG_MAX? I wasted one hour on this :(

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

    the answer can be greater than the INT_MAX value and since your are taking min then your result will be capped by INT_MAX and the possible result greater than INT_MAX will not be taken.

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

It's been a long time since I've received so many negative emotions from the C div 1 solution....

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

TAT

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

Feedback on the problem set:

  • A: Very good problem. I had seen something similar recently and this was immediate.
  • B: Standard problem, still enjoyable. I thought a bit in order to find a way to avoid a segment tree, but couldn't find any way. In the end, coded a segment tree.
  • C: Spent quite some time trying to prove a lower bound (without success), then I found a reasonable construction and guessed that it was correct (hinted by the number of ACs). The statement and the solution are nice, but I don't really like to encounter this kind of problems in a competitive programming competition.
  • D: Not read (skipped since the ranking suggested that E could be a better choice).
  • E: Okayish problem. It is rather easy for being an E. After few minutes I had the main idea, then I spent a lot of time getting indexes right (it was a miracle that I managed to submit it before the end of the contest).
  • F: Not read.

Thanks to the authors for the contest!

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

    Proving the lower bound in C is actually very easy.

    Let $$$k$$$ be the minimum value such that there are $$$k$$$ columns and rows without a queen. Then $$$n - k \leq Q$$$, where $$$Q$$$ is the number of queens you place.

    Since there are $$$k$$$ columns and $$$k$$$ rows without a queen, there are $$$k^2$$$ squares you need to cover with diagonals. These squares appear on at least $$$2k - 1$$$ distinct diagonals. Thus, we must have $$$2k - 1 \leq Q$$$ where $$$Q$$$ is the number of queens you place. Thus, $$$\max(2k - 1, n - k) \leq Q$$$, thus $$$\left\lceil \frac{2n - 1}{3} \right\rceil \leq Q$$$.

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

    For B, the segment tree can be avoided by maintaining two monotonic sets (one for positive-sum, the other one for negative-sum) and a map(when the sum is 0). Ugly code :/

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

    It is quite surprising to me that one might solve C in the way that does not immediately prove its correctness, hence I believe criticism on this aspect is unjustified. Here is how my line of thoughts looked like: https://codeforces.com/blog/entry/102013#comment-904940

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

      You are right when you say that once one finds the construction, then the proof is straight forward.

      I am not criticizing the problem because one can guess the solution. I don't like it because it contains zero computer science.

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

Let me try it: AtCoderForces

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

any hints for b and c ??

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

    For C iterate over each element and assume it to be 0 , calculate the number of moves to make all the elements after it to be increasing and all elements before it to be decreasing . Take the minimum answer for after iterating over every element.

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

And thanks to the authors for the exercise on DP with Segment tree

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

I hate this round.

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

    In every contest there will be someone who hates contest and may call it "Insert_a_topic_here" + forces . Instead we should focus on our skills and appreciate the efforts of problemsetters.

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

The comment is hidden because of too negative feedback, click here to view it

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

Don't look at ranks 160-200

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

enjoyed a lot solving CDE, solved only C, but anyway, great problems, thanks

(but B was a non-sense and stupid, such problem just SHOULDN'T be in div1)

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

is greedy + segTrees possible for D?

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

  image-2022-04-19-T16-22-07-267-Z

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

Places 160 — 200 of div2 have the same code for ABCD.

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

Some feedback:

I really liked ACD!

During the contest, I liked B, because I used the observation that there are no segments of size at least $$$2$$$ with sum $$$\le 0$$$, but as it can be solved entirely without this observation (with more segment trees), it's not a very good problem :(.

Also, E is pretty standard, but it's okay.

Anyways, thanks for the contest, I enjoyed it!

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

This is my solution for problem C

https://codeforces.com/contest/1668/submission/154109773

what's wrong?

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

    I think ans is not large enough, LONG_MAX is the same for INT_MAX

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

      I DON'T UNDERSTAND, WHY LONG_MAX CAN CHANGE ITS VALUE TO INT_MAX

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

        Because long is int in another name (It returns to the history of language)

        LLONG_MAX is the maximum long long in c++

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

Got a question about time constraints for PyPy 3. In Div.2C after coming up with O(N^2) solution I was reluctant to submit it for quite a while, because 25mil operations seemed like a certain TLE. What would you say is an appropriate op/s limit for PyPy here? Or are there some time adjustments and n=5000 should be an instant hint that O(n^2) is fine anyway?

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

Can someone tell me the test case fails for this code 154119937

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

i request the setters and testers to find out the same codes and penalise them

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

can anyone explain test case 2 of problem C of Div2? Shouldn't the answer be 8?

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

    No you need $$$3$$$ steps for the first and last element. You can only change $$$b_1$$$ with $$$a_1$$$.

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

Can somebody help me find out why my solution get TLE in pypy3, but accepted in pypy3-64 with only 514ms? 154083919

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

    I guess it's because division is an expensive operation and 64 bit pypy3 was able to handle the large number divisions better than the 32 bit version. This is what I thought before submitting my solution again after 2 TLE verdicts, but honestly I was surprised that it actually passed the pretests!

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

    Same here, and what a shame that I only realized the pypy3-64 existence in the last 10 minutes of the contests

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

I think it was on of the better recent rounds. I think that all problems were quite good and I have no significant points of criticism. Thanks for preparing it!

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

    Totally agree that all problems were good (maybe B was too standard and it were tempting to find a simpler solution). As always, this doesn't mean that the round was good too.

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

I unnecessarily wasted time in B thinking that they'll sit in order. I know that it was there in the explanation for a sample test case, but still could have mentioned that in the problem statement Peti chod.

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

SmallscoreForces

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

Nice round, thank you!

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

sus!!!?? His/her previous solutions got skipped and this contest's solutions also look sus! MikeMirzayanov

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

Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!

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

I think there are a lot of cheaters(aside from the videos that get uploaded on youtube during contest). And who is downvoting normal comments?(like 50+ downvotes for a lot of comms). Please ban their ip's because they can always make a new account)

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

Cheaters in div2 160-200 places. I checked about 10 accounts, all of these registered five days ago, all have the same code

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

here comes the cheaters on page 2 HtePhANA_ affianced.leon claudette_thomas_00

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

peti1234 for div2 problem B, my solution get an AC.

solution

but It should be wrong based on this test case:

1
1 4
3