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

Автор awoo, история, 16 месяцев назад, По-русски

Привет, Codeforces!

В 18.12.2022 17:35 (Московское время) состоится Codeforces Round 839 (Div. 3) — очередной раунд для третьего дивизиона. В этом раунде будет 7 задач, по сложности подходящих для участников с рейтингом до 1600 (во всяком случае, мы надеемся на это). Но, конечно же, участники с рейтингом 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов.

Вам будет предложено 7 задач на 2 часа и 15 минут. Мы надеемся, что вам они покажутся интересными.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того, являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Раунд основан на задачах муниципального этапа Всероссийской олимпиады школьников в Саратове и Саратовской области, поэтому если вы участвуете в нем — пожалуйста, воздержитесь от официального участия в этом раунде.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов и Максим Neon Мещеряков. Выражаем свои благодарности тестерам раунда: ermukanoff, soup, lankin.i, Fanarill, stAngel и senjougaharin. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

UPD: Разбор опубликован

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

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

Was this round supposed to be Educational round (Div.2) and then problems turned out to be too easy?

Asking because these authors usually make Educational Div.2 rounds and not Div.3 rounds.

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

Codeforces Round World Cup 2022 (Div. Final)

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

FIFA WC Finals:( If possible can change the timings pls:(

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

Hope to become Blue now!

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

Please change the contest starting time if possible. At the same time, the FIFA World Cup Final of 2022 will take place.

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

Can't It get shifted to some other day as tomorrow is world cup final and this round is DIV 3 which happen once in a while so don't want to miss this round

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

To everyone asking to postpone the contest, BledDest said in a comment on another blog that they can't do that because the contest is going to be based on some other contest. Here is the comment

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

Please change the time of the contest It's FIFA WC final match. It's also High-voltage match .Please change if u can. It's also the last chance of Messi (The GOAT).

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

I think round #839 will be poorly attended

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

Surely going to miss the round(FIFA World Cup Final).

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

Kinda excited for my first unrated Div 3 round !!

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

awoo, FIFA World Cup Finals: If possible can change the timings please. I don't want to miss Messi's final and Div 3 Round.

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

The only way to watch the World Cup Final is AK this round in 25min.

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

We need more Div 3 and possibly Div 4 rounds. I find Div 3 problems more interesting.

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

This contest is going the have the least submissions!

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

This contest is going the have the least submissions!

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

HAHAHAHAHAHAHAHA

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

Argentina!

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

Hoping for both +ve delta and Argentina win!!

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

I see, that people between 1600 and 1900 rating are trusted participants. But a little higher it is said that above 1600 people can register only unofficialy. Does this contest affect rating for people between 1600 and 1900?

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

    Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

    So if your rating was >= 1600 it wont get affected.

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

lol

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

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

Vamooos

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

Heart Says Argentina but Brain says France. Messi Deserves atleast one.

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

If that wasn't the last world cup of Messi, I surely would participate in the contest. Got to see the match. Best of luck for those who are attending. And best of luck for Team Argentina.

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

Thankyou awoo for keeping this at the same time of FIFA World Cup Final. I can't watch the match because of anxiety. So, it's good that I'll have something else to do. Vamos Argentina! Messi is the GOAT regardless of the outcome.

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

Contest during the world cup final? What a great idea. Now Messi and Mbappe won't be able to write this contest :(

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

Nah bro, I thought the start time would be changed... Unfortunately I have to miss the contest, not gonna miss the wc final.

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

Excited!! As this would be my first unrated div.3 (~ ̄▽ ̄)~

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

This contest will have the least Argentinian participants of all time.

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

Argentina!!!

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

Wow, i am so impressed. Haven't seen such decent problems in a while, great work!

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

Solution for problem E:

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

    how to solve d?

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

      consider two adjacent elements. for a particular value of x the element will flip. by flip I mean their sorted-ness will reverse. find this flip value for all adjacent elements. there are two kinds of adjacent pairs — 1)ones that are v[i]<v[i+1] and 2) ones that are v[i]>v[i+1]. the max flip of all second kind of pairs should be less than min flip of all first kind of pairs thats what i did. also find x accordingly

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

    DID THE EXACT THING. I AM IMPROVING (´◡`)

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

loved the problems. Solved 5, max till now in div3. Hoping to be Specialist

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

How to solve D ?? I tried binary search but it did not work :( hints plz

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

    Find the valid range of $$$x$$$ s.t. $$$|a[i]-x| \leq |a[i+1]-x|$$$ when $$$a[i] < a[i+1]$$$ and when $$$a[i] > a[i+1]$$$

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

    Consider some index $$$i<n$$$.

    • If $$$a_i<a_{i+1}$$$, this pair will remain in sorted order for all $$$x\leq \lfloor \frac{a_i+a_{i+1}}{2}\rfloor$$$
    • If $$$a_i>a_{i+1}$$$, this pair will become sorted for all $$$x\geq \lceil \frac{a_i+a_{i+1}}{2}\rceil$$$

    By iterating over the whole array, we can generate a lower bound and an upper bound for $$$x$$$. If at any point we require $$$x$$$ greater than the upper bound or lower than the lower bound, it's impossible. Otherwise we can return any number within the range obtained.

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

      How to think about these tricky things? On some days/contests I am to find these but on other days/contests not. Due to this, I am struggling between specialist and pupil. How do you come up with these in every contest?

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

        Speaking from my experience, upsolving and lots of practice helps :)

        After doing a few similar problems you'll start to notice common methods of approach and get a feel for which of them is most effective in each type of problem. During the contest try to find the most suitable approach, or just try them all until you find one that works.

        For this particular question I was trying out simpler cases, my thought process went like this:

        • If the array is sorted in reverse, then any $$$x$$$ larger than the first value will work.

        • If we have an unsorted section like 4 2 6, we need to find a value between 2 and 4.

        • Instead of considering the whole array, can we consider parts of it and find bounds for $$$x$$$?

        Then I worked out the algorithm in my earlier comment. A more experienced contestant might be able to immediately see that we consider pieces of the array due to having solved similar problems with that approach earlier or having seen the technique mentioned in an editorial. Hope this helped you!

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

Solved A/B/C in 20 minutes, then misunderstood D and coded up a wrong solution, and then keep getting stuck with E with a solution I could've sworn was correct, and fixing it 1 minute after the contest. Sigh.

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

how solve 3rd problem I was unable to implement it, can anyone explain it?

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

    I can't prove my solution but I just printed 1, 2, 4, 7, 11, 16... <= n for each case and then inserted the k greatest leftover numbers at the end of the array and sorted. I figured I maximize the number of distinct differences this way and it's better to fill in the extra k with larger numbers than smaller numbers because they have less of a chance of messing the array up.

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

    Start from the last index and make it equal to n. Let's keep track of the last used difference and call it P. For each i such that 1<=i<k check if a[i+1]-P-i+2 is greater than 0. If it is true, then a[i]=a[i+1]-P+1. Else a[i]=a[i+1]-1

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

Hi! This is my first CodeForces contest, and I was expecting that this would result in some rating for me, as the notification email said rated for < 1600. I completed the contest, but it says unrated on my profile. Why is this?

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

Why it fails in D taking middle between our element and first unsorted element and checking

if(that works)good else cout-1

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

    You don't necessarily have to take the middle element it actually is the bound. For example if you have 3,11 middle element is 7 which implies any x<=7 can be the answer similarly if it is 11,3 any x>=7 can be the answer You can find out the final range of x which satisfy the condition by changing the upper and lower bound considering each pair of elements

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

    I Do it like checked if 5 x x x 5 Then between the two same , all have to be same since border is same on applying opeartion

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

    Try it for [2,6,0,6]. Answer for it would be 3. I wasted a lot of time finding this one.

»
16 месяцев назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится
This is fine...
»
16 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Where can i see test cases for D, it shows wrong answer but cant see on which test case is wrong answer?

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

Overtime specifically for Codeforces!

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

problems D was brilliant I am happy I was able to solve it
perfect Contest if any one needs help in it donot hesitate to contact me here is my solution;185847933

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

I think problem D was way better than problem E.

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

    I feel the same after seeing E I cannot figured out it in contest as got exhausted after solving D but E was way easy than D

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

Argentina WON!!!

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

THE MAGIC MESSI STRIKES AGAIN!!!!!!

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

Why did a lot of guys put

if(t==1) return 0;

in A, which actually gives a wrong answer if t = 1. Is it just a coincidence or is there some hidden technique that they tried to use and it failed?

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

How to solve F or G? Can someone help?

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

    For problem F: The first observation is that if we count the number of positions whose values can be flipped in each of the copies, the copy with the highest count will be the initial one and the count of subsequent copies will decrease. So we now know in which order the copies are taken (I used a max heap for that). Then for individual operations, we compare the current copy with the last copy and the positions where the value is different is the position where operation 1 was performed. And operation 2 is performed for each copy after all operation 1s.

    here is my solution 185868920

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

      Nice.

      My thoughts were that it is easy to determine for any two pictures whether one can be obtained from the other, so we can build a graph on all pictures and find the longest path, than figure out the transitions on the edges of the path...

      But it was too troublesome to implement, so I gave up

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

      Isn't it possible that when a value is flipped, it leads to the generation of more such values?

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

        No, because

        if a position is being flipped, then all its 4 neighbors are already the opposite value, So the position we are flipping will never be adjacent to the same value in that case it would be invalid to flip itself

        consider an example to understand what i am trying to say
        0 1 0
        1 0 1
        0 1 0

        By changing bolded 0 to 1 would never lead to a situation where it shares a side with a 0.

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

      For problem G: Firstly sort the array. now, let our cur_rating be rating when we just win the match with the ith element.In the beginning the value of cur_rating is x. If we are at ith position and a[i]>cur_rating, then we have to cross the barrier by gaining a[i]-cur_rating for move further.if we are at ith position, we can win all the games with all players having index less then i[(i-1) player] and we will lose all the games with all players having index greater then or equal to i [ (n-i-1) player] so total gain we can get in 1 loop is simply (i-(n-i)). now we can calculate total numbers of games for crossing a[i]-cur_rating.if our cur_rating will reach at y we will stop.At the end of loop we are at the stage when we can win with every element.

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

    Problem G: Let $$$bonus$$$ be the ratings of $$$x$$$ getting in all games.We can calculate $$$bonus$$$ by doing binary search until $$$bonus$$$ has no change.If $$$ x + bonus \geq y$$$, the game ends.If $$$bonus - (n - bonus) \leq 0$$$, we cannot win the game.Find $$$f$$$ that $$$x + bonus * f \geq a_{bonus+1}$$$ ($$$a$$$ is sorted), which means we need repeat $$$f$$$ rounds and gain same ratings until we can get ratings from a new game.Note that $$$y$$$ may in $$$[a_{bonus+1}, x + bonus * f]$$$, so just add $$$bonus * (f-1)$$$ to $$$x$$$.

    My Submission:https://codeforces.com/contest/1772/submission/185846915

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

Problem D Solution : Basically I checked the case of a[i] > a[i+!] => found out the maximum a[i] — ( a[i] — a[i+1]) / 2. Why this? Because this pair will become sorted for all x >= (a[i] + a[i + 1] + 1) / 2, came to this conclusion after testing it out on paper. And then iterated over the whole array and subtracted each element with this resultant value. At last, I just checked the sorting condition.

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

How to solve C and D ?

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

    For problem C:

    Spoiler

    For problem D:

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

problem F looks little scary by looking but it is very easy to solve.

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

my rating is less than 1600,why this contest unrated to me?

(sorry for my bad English)

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

Those who participated in this round please get life because it looks like it matched the world cup finals lol.

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

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

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

I submitted this code. This work on my laptop but not in Codeforces. https://codeforces.com/contest/1772/submission/185900333

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

I happily ruined my entire contest by watching the FIFA final, but that was worth it!