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

Автор 300iq, 2 года назад, перевод, По-русски

Привет, Codeforces!

Мы приглашаем вас поучаствовать в Good Bye 2021, который пройдет в 29.12.2021 18:35 (Московское время). У вас будет 2 часа на решение задач. Раунд рейтинговый для участников обоих дивизионов.

Задачи были подготовлены 300iq с помощью потрясающих координаторов KAN и 74TrAkToR.

Мы благодарим всех тестеров, без которых этот раунд бы не состоялся: gamegame, thenymphsofdelphi, ko_osaga, golions, Ashishgup, izban, prabowo, 74TrAkToR, Devil, manish.17, taran_1407, minhcool, AlFlen, Utkarsh.25dec, NemanjaSo2005, wxhtzdy, ajit, mnaeraxr, Scrubpai, YashDwivedi, eatmore!

И, конечно, спасибо MikeMirzayanov за потрясающе платформы Codeforces и Polygon.

Этот раунд проходит при поддержке компании NEAR, которую основал бывший участник соревнований AlexSkidanov. В команде, разрабатывающей NEAR, работают многие известные участники сообщества, включая дважды чемпиона мира ICPC eatmore и победителя GCJ и TCO Egor.

В раунде предусмотрены призы для участников, которые займут первые 255 мест. Победитель раунда получит Ⓝ128, участники на втором и третьем месте по Ⓝ64, участники на следующих четырех позициях по Ⓝ32, и т...

NEAR — это современный протокол блокчейна. В прошлом месяце на NEAR запустился проект CrowdForces, который позволяет участникам первого дивизиона получать NEAR за создание простых головоломок. За регистрацию на CrowdForces вы сразу получите 1 NEAR. Подробности здесь: https://nearcrowd.com/crowdforces

Если вы не в первом дивизионе — не беда! Присоединяйтесь к открытому для всех хакатону Metabuild с призовым фондом в $1M. Подробности: https://metabuild.devpost.com/

Надеемся, что вам понравятся задачи! Удачи!

Поздравляем победителей!

  1. tourist
  2. ecnerwala
  3. ksun48
  4. Radewoosh
  5. Benq

UPD: Разбор

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

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

woah 300iq is back

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

What is Ⓝ...?

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

As I tester I can confirm that round has some interesting problems. I hope that you will enjoy them and the last round of 2021 (I think).

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

N64

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

I noticed that the hackathon is open to "Individuals who are at least the age of majority where they reside as of the time of entry." Does this mean that individuals who are minors cannot participate?

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

    I suspect this is due to legal issues with awarding prizes. If you can find someone who's over the legal age of majority in your country to claim the prizes (shall you win some hackathon track) you should be good to go.

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

      Hm. I don't want to break any rules. Just to clarify, I can participate if someone else who is a legal adult claims the prize for me?

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

        I think that should be fine. Fancy seeing someone from Redmond here.

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

Is it rated?

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

Why only 2h :(

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

omg 300iq orz

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

Best present.

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

We would like to thank all the testers, who made this round possible. They will be added to this blog later.

Translation: testing will commence soon.

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

Unusual time alert missing!!!

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

What if NEAR bankrupts ? Are the winners going to win money ?

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

How many problems will be there in this round? 300iq

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

Happy new year ~ ovo

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

Such as a great year for me! Best of luck for everyone.

happy coding :)

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

Me during contests

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

3 contest in 3 days.For me its overwhelming !!

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

How many problems? and Why only 2 hours, Good Bye 2020 and Good Bye 2019 was 3 hours!

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

i heard Ⓝ1 worth about $13.5, so the total prize is Ⓝ1024 ~ $13800

that's a really big amout of money(to me)... i cannot imagine

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

Good Bye 2020
edit : why so many downvotes , i just pasted the link of last year's contest to help people searching , wanting to solve it

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

Weren't you guys making some kind of CP solving AI? What's up with this switch to blockchain?

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

All the best everyone :) Hope I reach pupil in this contest ! Wish me best of luck

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

How many problems will be there? 300iq

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

Last One

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

Can we know how many problem there will be yet?

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

I wish my rate became 2021 but I'm still living in 10th century

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

score distribution pls, i really wanna do some useless analytics five minutes before contest

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

Score distribution and problem count to be posted after the contest. Should add a new strategic element.

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

Is this round only for those who don't care about the number of problems and their score distribution?

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

The suspense to the score distribution is as much as the suspense as to how 2022 will turn out to be.

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

I have seen many Oops! today. Maybe it's good to participate from the mirrors:
m1 m2 m3

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

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

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

Looking forward to receiving 1 Near coin! Might be able to afford a lunch.

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

WA3 in problem C is a nightmare

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

2022 ? yesterday was 2019:"

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

i feel d is easier than b and c :/

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

    How to solve D?

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

      How to solve C ?

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

        How to solve B?

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

        For the array to be good, it's sufficient that the sequence is in Arithmetic progression. So try to fix two elements and check how many elements we should change in order for the sequence to be in AP.

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

      If there exists any bad $$$r$$$ for a given $$$l$$$, there will always exist some bad $$$r$$$ that is at most $$$l + 2$$$ (or at least $$$l + 9$$$ since I didn't have the guts to submit with $$$l + 2$$$). As for how you prove this I have no clue, I couldn't generate a counter-case so I submitted lol (inb4 pretests are weak and I FST).

      The intuition mostly arises from any two adjacent values $$$\lt x$$$ being bad. If that isn't the case then they must alternate between $$$\lt x$$$ and $$$\geq x$$$, so if the whole range satisfies some prefix satisfies or something like that, I tried generating a two really small ends case but couldn't come up with anything that took more than $$$3$$$ so I just guessed it at that point.

      Now you have a number of ranges of the form $$$[l, r]$$$ that must be covered with at least one point, so just use the standard idea — sort them by $$$r$$$, skip them if $$$l \geq \text {last removed}$$$, otherwise remove it and set $$$\text {last removed} = r$$$ (last removable point to make as many ranges as possible skippable).

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

        Ohh pretty cool. If for any $$$l$$$, bad $$$r$$$ <= $$$l + 2$$$, then this can be solved using simple dp as we don't have to consider a lot of cases.

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

          DP isn't even necesary if that fact holds actually. If you can identify all such ranges, it becomes a problem of choosing the minimum number of points that cover all ranges. This can be solved by processing the ranges in increasing order of their right points and greedily removing a point only when we reach the end of an uncovered range.

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

        The proof is that every sequence can be split into chunks of 2 and 3, and the overall mean is a weighted average of these chunks.

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

        If there exists any bad r for a given l, there will always exist some bad r that is at most l+2 (or at least l+9 since I didn't have the guts to submit with l+2).

        I was able to solve this problem without the above observationl(actually, I was not able to come up with this idea at first lol). Observe that sum of a segment $$$[l,r]$$$ is negative iff $$$pfx[r] - x \times r< pfx[l-1] - x \times (l-1)$$$. Therefore, for every $$$j$$$ we need to find the largest $$$i(< j - 1)$$$ such that $$$arr[j] < arr[i]$$$, where $$$arr[k] = pfx[k] - x*k$$$. This can be done by modifying the standard method to find the nearest smallest element in the array $$$arr$$$.

        Submission : 141149652
        But this solution is an overkill if you have got the above observation.

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

      Subtract $$$x$$$ from everything, now it's asking for segments such that every subsegment has a non-negative sum. You can find it by checking the leftmost $$$l$$$ such that $$$[l,i]$$$ has a non-negative sum and then doing a simple DP.

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

        woah :o that's a great solution. from submissions, I see most people got this idea. don't know if that's a standard observation for such problems.

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

        What a simple solution!

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

        For the segment mentioned [l...i], In the dp phase, we will either choose the whole segment or leave it correct?

        If we choose it how can we say it has all valid subsegments ([l...i-1] , [l+1....i-1]...)?

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

          For the segment mentioned [l...i], In the dp phase, we will either choose the whole segment or leave it correct?

          Yes, that's correct.

          If we choose it how can we say it has all valid subsegments ([l...i-1] , [l+1....i-1]...)?

          You can keep track of this with $$$l[i] = max(l[i],l[i-1])$$$. You can see my submission for more clarity.

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

      Greedy,

      an important observation i found is if all subarrays in triplet $$$(a1,a2,a3)$$$ satisfies the given condition, if $$$(a3,a4)$$$ satisfies the condition then $$$(a1,a2,a3,a4)$$$ will also satisfy the condition.

      so maintain a variable $$$last$$$ which holds the last unselected index(initially $$$last=0$$$)

      so start from $$$i=2$$$ and first check for subarray $$$[i-1,i]$$$ ,then $$$[i-2,i-1,i](if possible) $$$,if it doesnt satisfy the condition , unselect i ,and repeat this process.

      sorry for my bad english.

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

      Initially we have:

      a(l)+a(l+1)+…+a(r)≥x⋅(r−l+1) -> a(l)+a(l+1)+…+a(r) — x⋅(r−l+1)≥0

      We can reagente to (a(l)-x)+(a(l+1)-x)+…+(a(r)-x)≥0, so we can do a[i]-= x and only care if a(l)+a(l+1)+…+a(r)≥0.

      Now we can use prefix sum to write this as ps[r] -ps[l-1]≥0

      The idea now is for each i, you will not select i if some ps[r] — ps[j] < 0, with (the last index not selected) < j < r-1

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

    Jeez should have searched for this. Thanks though for the link!

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

      We just need to change our array into some AP. That's what I searched xD.

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

        Lol. I did the same things xD. My idea was Sn of AP = n/2.(a0+al) and its 1/2*(a0+al).(r-l+1) and somehow I have to convert the array into AP and I googled it xD and got this.

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

    Did the same exact thing. Unfortunately WA on tc 3 :(

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

Can someone link the recent opencup problem that was H but instead of counting maximize the size of the set? I forgot which opencup it was.

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

How to solve E?

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

    The resulting string s will be a prefix of t with the first character difference after less than the corresponding character in that position in t. We can just iterate this and use a segtree or something to maintain the minimum number of operations needed to transform to that prefix. Time is $$$O(n * 26 * logN)$$$.

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

    if there is any transformation of s in mimimum moves such that new string is smaller than t

    then that s will be converted to below transformation —

    (t[0]+t[1]+...+t[i-1]+c+X)

    where c < t[i]

    and X contains remaining characters of s.

    Iteratively, we can find moves required to transform s into all of the strings of above type and return minimum of all.

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

Solved only one problem, I want to die

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

How to solve C?

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

    you should convert array into arithmetic progression and for this it's sufficient to iterate over all possible $$$i, j$$$, fix this 2, find current $$$d$$$ ($$$d = (arr[j] - arr[i]) / (j - i)$$$) and make arithmetic progression with this $$$d$$$, then for each generated array find the one with minimum difference with old array

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

      it results in O(n^2) can we optimise it??

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

        maybe there exists more optimal solution, but this is also pretty fine to get AC(because of input size)

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

      why we need to convert the array into arithmetic progression? what is the intuition behind it? how you come to the conclusion that making AP is the key idea to solve this problem?

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

        The Sum of an AP is n/2.(a1+an) and in this question we were asked that a1+a2+a3+....+an = 1/2.(a1+an).(r-l+1) . Now r-l+1 is the number of terms i.e. n . So we can say that a1,a2,a3...,an are in AP and their sum is 1/2.(a1+an).(r-l+1).

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

        the reason is quite simple:

        every subsegment must be arithmetic progression(because this formula is correct only for AP-s), which definitely means -> whole array must be AP(because the array itself is the subsegment of it). Then, if the array is AP, indeed, every subsegment is also an AP, so this condition is necessary and enough too :)

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

    I thought of C as fitting a line. Each pair of points can form a line x being their index and y being array value. You need to find the line which has the most points lying on the line. The points which are not on the line is the answer.

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

I tried finding the largest size of subsequence that is an AP sequence for C(then subtracting from N to get ans) but its TLE. Can anyone explain their solution?

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

    Fix any two elements of the array and get the common difference of the AP according to those two "fixed" elements. Now adjust all other elements accordingly. Among all n(n-1)/2 cases, the one requiring minimum alterations corresponds to the required answer.

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

      after fixing the 2 numbers how did u check.

      did u had everything in double datatype?

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

        You can also rewrite the equation and write the condition with integers.

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

          could you please elaborate this.

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

            For example in the submission that exulansis linked he checks the following condition: v[k]!=a+d*(k-i).

            You can replace d there and you get v[k]!=a+(b-a)/(j-i)*(k-i) and if you multiply both sides by (j-i) you get v[k]*(j-i) != a*(j-i) + (b-a)*(k-i) which are all integers.

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

              Nice. This is better. You don't require to worry about floating point error

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

    Just realised my stupidity. This is in fact a viable solution. But i was not doing what i described here. Lol, so I came up with the solution while trying to ask for help.

    UPD: The one I proposed here is actually wrong and the one I was doing in-contest is right but is way too slow.

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

      This is actually not a correct solution. I got stuck on this approach, but here is a counterexample:

      2 1 6 8

      The answer is 1, but doing what you described gives 2.

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

WA on B was the most irritating

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

I haven't proven it yet, but for problem E was it enough to try to find the nearest character in s equal to the current one we are evaluating (iterating through the target string t)? To update the answer, then we just find a smaller character instead. The idea would be to do this with Segment tree / BIT,

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

Was not able to do the kindergarten math of C :/

And noticed after contest that it is also doable with doubles instead of fractions which is even simpler.

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

due to lags in the last 10 seconds, I didn't have time to send problem H (let's see if it works later...)

upd. no :)

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

Did anyone else think there were some server issues during the contest? It took me around 30 minutes to just get to read the problem statement of B, not even the lightweight sites were loading for me. Wanted to see if this was a server issue or a local one, because other sites were loading...

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

    Same for me. Codeforces only worked for me in the last ~30 mins and even the lightweight websites were taking too much time to load. I was using a different internet connection today, I thought it's because of that.

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

    Its Working properly In my Case

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

Today, i literally understood the meaning of laxicographically smaller.

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

Happy new year everyone <3

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

In whole contest the codeforces not worked properly,uneccesrily buffering . : (

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

One thing you should learn:

  • For every div.1+2, H is easier than F
»
2 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Any one felt server is slow?While contest

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

    Exactly! Even the lightweight sites were refusing to load, I thought it was a local issue, but others were having problems too, and other sites were loading fine

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

      It is taking 30-40 seconds to reload the standings and submissions :( .

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

What's the idea behind B?

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

    You just had to take the longest nonincreasing prefix of the string and mirror it.

    The only corner case is when the first two characters of the string are equal, in this case just take the first character and mirror it, as all possible generated strings are guaranteed to be lexicographically bigger that it.

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

      This problem B derailed my contest. Seeing the number of successful submissions made by the others, I had a feeling that I was just missing something obvious. In the end I got some sort of an overcomplicated mix of greedy and DP (keep increasing 'k' as long as the new string becomes lexicographically smaller than the previous one and use DP for doing fast amortized O(1) comparisons of these strings). Unfortunately I was just a few seconds too late to submit it during the contest time and got interrupted by the "end of contest" banner. Okay, no luck getting back to blue in 2021, but hopefully 2022 will be better.

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

Short statements, really interesting problems, and good distribution. Thanks, 300iq!!

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

Are you aware that a problem very similar to H (max clique instead of number of all cliques) was on an OpenCup on 5th December ;d?

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

    Well, unfortunately I was not aware :(

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

    It is also kinda funny considering the fact that I've created this problem two years ago. In the 300iq Contest 2 there was a version with $$$\geq$$$ instead of $$$\leq$$$, because I couldn't solve $$$\leq$$$ back then :)

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

can somebody explain me this

code actual

141111062 this is my submission

when i run the code in custom invocation (top right bar on codeforces) the execution time is 3478
while if i just comment the if condition

like this

the execution time is just 452
why????

in case someone is intereted in test case
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

any idea for E ???

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

    Greedy. Iterate through the string $$$t$$$. For each position, we either find the closest character in $$$s$$$ that is strictly smaller than the current one we are evaluating on $$$t$$$, or we just find the closest equal character and move on. The number of swaps required to properly position each character we pick is $$$pos + sum(pos + 1, n) - i$$$, where $$$pos$$$ is the position of the character in $$$s$$$, $$$i$$$ is the current index of $$$t$$$ and $$$sum(pos + 1, n)$$$ is the number of characters previously taken that are on the right of $$$pos$$$. Code : https://codeforces.com/contest/1616/submission/141130793

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

Haha, I just bruteforced my way through C and prayed that it will pass =) 141117223

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

Can anyone please explain how we can tackle E? I read the comments above but still have no idea

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

Is D solvable using segment tree?

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

    It is I believe. Everule solved it using segment trees (141109186) in contest though I don't know what it does as I cannot comprehend how his brain works.

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

      First we subtract $$$x$$$ from all elements, and now we need all subarrays of more than one element to have non-negative sum.

      I calculate the minimum $$$lim_i$$$ such that $$$[i \ldots lim_i]$$$ is an invalid range. For that let $$$p_k$$$ be the sum of the first $$$k$$$ elements. Notice that $$$p_i \le p_{i+2} \le p_{i+4}$$$ for the range $$$[i \ldots i+4]$$$ to be valid, so the value of $$$p_i$$$ becomes irrelevant after a certain range, in which case the maximum range is the same as for $$$i + 1$$$. If it becomes invalid earlier, then you can do quick brute force on small subarray.

      Then I just iterate over where the next removed element is, as element $$$i$$$ being closed means that there is some element before $$$lim_{i+1}$$$ that is closed, and we take the minimum dp value among those. You could also probably do $$$O(n)$$$ for this but I didn't think that much.

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

    I solved it using segment tree. First of all, we need to ignore an element from a subarray $$$[l, r]$$$ only if $$$ps(r) - x \cdot r \lt ps(l - 1) - x \cdot(l - 1)$$$. I call such subarrays "invalid subarrays". Note that $$$ps(x)$$$ here means prefix sum upto index $$$x$$$ ($$$1$$$-indexed).

    Say $$$F(i) = ps(i) - x \cdot i$$$. First, I precompute all $$$F(i)$$$ and store it in an array $$$V$$$. Now for any invalid subarray to end at index $$$r$$$, we need atleast 1 $$$l$$$ such that $$$F(l - 1) \gt F(r)$$$.

    We maintain a segment tree where index $$$i$$$ stores the largest $$$l$$$ such that $$$V_i$$$ is the largest value $$$\lt F(l - 1)$$$.

    In this way, while iterating over the array and updating and querying the segment tree, we can find out for every invalid subarray ending at index $$$r$$$, the largest starting point $$$l$$$.

    Once we have all $$$r$$$ and corresponding $$$l$$$ values, we can greedily choose what indices to not pick so that we have to (not pick) the minimum amount of elements.

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

Stupid problem F. A $$$\mathcal O(m^{3.5})$$$ solution is so obvious that I think there will be testcases to let it TLE. but everyone's naive Gaussian elimination implementation passed F in 31ms.

It's like, a simple tripartite graph with $$$9 + 9 + 9$$$ vertices and $$$3 \cdot 9 \cdot 9$$$ edges, and $$$9^3 = 729$$$ triangles, can let my solution spend 280ms in naively eliminating the linear system. But you didn't put any of similar graphs into the testcases.

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

    I didn't dare to write it for a long time, worrying about TLE..

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

    I doubt that there is no big tests in the testcases. I think that this particular solution is just very fast. You can try to hack all these solutions if you think you know how to

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

      There was no big test in the systests. I was able to uphack a few of the AC solutions for TLE -- for example: https://codeforces.com/contest/1616/hacks/779744

      It's true though that the constant factor on this solution is very fast. However I don't see any reason that this problem needed to have 10 tests at a time and only 1 second for the time limit.

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

        You can work mod 3 with bitsets, maybe they wanted to cut solutions that didn't use them?

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

      Unfortunatly due to the relatively small constant of Gaussian elimination, even my naive implementation passed it in 850ms (141133870). (with absolute no pruning, I just used traditional Gaussian elim. but not the Gauss–Jordan elim., so there’s smaller constant)

      I tried the tripartite graph of $$$[9, 9, 9]$$$, and the complete graph $$$K_{23}$$$ but both cannot let the implementation TLE. (actually an observation is that, any $$$K_5$$$ must be monochrome, my first code used this fact to reduce the constant)

      It seems that 300iq intended to let these naive solutions to pass. But I think the simple observation of “ $$$1 + 2 + 3 \equiv k + k + k \equiv 0 \pmod{3}$$$ ” is not worth an F in a combined round.

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

    Exactly, when I read problem F for 2 minutes before solving E, I immediately got that solution and thought "Lol get back to E, I am under-estimating this" because of only 30-40 solves.

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

    You can actually get way more triangles, around $$$1771 = \binom{23}{3}$$$ with a clique of size $$$23$$$.

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

      The reason of why I didn’t use $$$K_{23}$$$ is any $$$K_5$$$ must be monochrome, and maybe some solutions can check this to reduce the number of variables and equations. (actually myself considered this. But after the contest ended, I realized that I’m overthinking, and I’m very frustrated because of the puzzling constraints)

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

    Similar feelings about E: firstly I wanted to fast write $$$O(26nlogn)$$$ with splay tree but thought it will TLE and I spend ~20 minutes to achieve $$$O(nlogn)$$$ with BIT. Splay passed in 62ms in upsolving...

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

Can anyone please tell me the mistake in this code for problem C

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

    It might be due to double / float being not precise. It is better to implement this using int. To do this, instead of dividing $$$x$$$ by $$$(j - i)$$$ at the initial step, you check whether $$$(a_j - a_i) \cdot (k - i) \% (j - i) \neq 0$$$ which means that the result is a floating point number, otherwise you can get the expected value of $$$a_k$$$ to be $$$\frac{(a_j - a_i) \cdot (k - i)}{(j - i)}$$$.

    You can view my submission here: 141082107

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

It seems for E, you can just copy and paste this , modify it a little and run binary search to get K. Unfortunately, I was unaware of it and coded a solution from scratch... RIP rating

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

    Are you seriously saying that being unable to copy paste an existing solution is unfortunate? Yikes.

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

Hi, This contest has a lot of traps (eg. Problem B, C). May I ask that how do you all do testings other than stress testing to find out the wrong proof that we have made? I am very often stuck in these kinds of situations where my solution is mostly correct but due to tricky edge cases or wrong assumptions (for eg my problem C) that I could,t find out I was a mistake. I wish that I could get some help in facing these situations because I quite often faces these issues. Sorry for the bad english. Thank you very much.

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

I am so sad. After I solving the Problem C I am nearly 70th, But after I solving the Problem D I am nearly 700th.

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

    I use a dp to solve the Problem but I think it is too hard. So I use greedy and pass the pretest suprisely in the end. It takes me nearly 1h. Is there anyone have an easier solution? Many thanks.

    My stupid greedy

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

      The first part of my solution is similar to yours: subtract $$$x$$$ to all the elements of $$$a_i$$$ so the problem becomes make range sums non-negative.

      Then, we use the following greedy algorithm:

      Iterate from $$$i=1$$$ to $$$i=N$$$, let us assume that $$$j$$$ is the maximum index smaller than $$$i$$$ such that $$$a_j$$$ is not selected. Then, if there exist any $$$k$$$ where $$$j < k < i$$$ and $$$\sum_{x=k}^i a_x < 0$$$, we can delete $$$i$$$.

      To implement this, we can store the prefix sums of $$$a_i$$$ and keep track of the maximum prefix sum when we iterate from $$$i=1$$$ to $$$i=N$$$.

      You can see my submission here: 141100821

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

When will ratings be updated?

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

Codeforces is taking longer time than usual to reflect the rating changes :(

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

Please add tutorial, looking forward to read approaches for D and E problems

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

what is error in my solution for problem b my solution

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

    wrong answer 8th lines differ — expected: 'baaaab', found: 'baab'

    for input: baa

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

When will ratings be updated??

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

    you can use CF predictor to get approx idea about what your rank will be be. I understand the excitement before announcement of ratings

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

Can someone find the mistake in my Problem-C solution?? link to my solution. https://codeforces.com/contest/1616/submission/141148146

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

What is error in my solution for problem C . It is failing in 7th testcase.

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

    you have used double as data type for the common difference. instead of this you should have cross multiplied the denominator value with all terms in the equality statement

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

    Your solution is failing probably due to comparison operator (!=) you are using in inner most for loop arr[k] != a + k * d. This way of comparing double is inappropriate. Replace that line with : abs(arr[k] — (a + k * d)) > 1e-10 and it should pass !!

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

When will the rating be updated?

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

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

Editorial of this contest is published https://codeforces.com/blog/entry/98501

somehow they didn't linked it to this post

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

In problem C,7th testcase was not included in system testing!!

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

Anyone else waiting for rating change to see that beautiful purple color of candidate master

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

Can someone please clarify why the 7th test case was not included in system testing for problem C ?

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

Please tell me how to get the reward of this competition

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

Hi, my solution for problem 1616B (141080537) and the solution ti21_phnam (141107393) was found to be too similar by the system. We believe that there is nothing similar in them, except for the title, but this is a comment. Can the authors of the round or the admins deal with this situation?

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

Yet another young LGM in China ,He_Ren orz.

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

And where did you guys take DIV 3 and Div 4 contests? Not all of us are in the elite league consider!!!

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

    Do you realize that beginners get more resources than anyone else? You get more contests, more tutorials, everything. And yet you demand more. Be happy with what you get. Div 2 contests are completely suitable for you. Don't be so entitled to expect everything to be tailor-made for you.

    Further, the last Div. 3 was a whopping 10 days ago. That's a normal gap.

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

      He is not wrong tho. You guys even participate in div3. Solving questions in like mins or so and When we get stuck, (and check the leaderboard by mistake), you guys have already finished the contest. It demotivates the shit out of us.

      Talking about div2, Sometimes it is difficult to crack even A. But you guys, make it look so easy that anyone below you, if asks for something(like the comment you replied to), You guys treat it like its worth nothing. -is-this-fft-

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

        I think if you get demotivated by the existence of people better than you then it is hard to accomplish anything in life; Codeforces should not take such feelings into account.

        When I started, there was no such thing as Div 3. And people managed to improve just fine. The whole existence of Div 3 is IMO a big favor.

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

Wrong solution marked correct My solution of the problem C has been marked as AC in the contest. AC SOLUTION However this solution is incorrect possibly due to floating point precision. On trying to resubmit the problem now it's giving WA on test 7, however in the contest there were only 5 tests and the solution was able to pass all those tests. Would you please revaluate the solutions? @thenymphsofdelphi @74TrAkToR @gamegame @300iq

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

    It could be that extra tests got added after system testing. In that case it isn't right to rerun systests since it could be done forever.

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

      Well that sounds right! I understand the thing, however it’s weird to know that the testcases were weak enough to make some wrong solutions pass. Thanks for the input

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

Let's use the new feature!

Problem A:

liked:
disliked:
neutral:

Problem B:

liked:
disliked:
neutral:

Problem C:

liked:
disliked:
neutral:

Problem D:

liked:
disliked:
neutral:

Problem E:

liked:
disliked:
neutral:

Problem F:

liked:
disliked:
neutral:

Problem G:

liked:
disliked:
neutral:

Problem H:

liked:
disliked:
neutral:

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

Hi! I got rk12 in the goodbye round. However, I only received Ⓝ0.1 rather than Ⓝ16. I guess it's because I changed my handle after the contest. What should I do now?