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

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

Hello Codeforces!

Невероятно рад пригласить вас на Codeforces Round 860 (Div. 2), который пройдёт в 26.03.2023 17:35 (Московское время).

Раунд будет рейтинговым для всех участников, чей рейтинг ниже 2100. Участники с бóльшим рейтингом приглашены принять участие в раунде вне конкурса.

Вам будет дано 6 задач и 120 минут на их решение. Все задачи раунда придуманы и подготовлены мной.

Традиционный список благодарностей всем, кто принял участие в создании раунда:

🤴 DishonoredRighteous за координирование раунда

🐞 gyh20 за чёрно-красное тестирование раунда

😈 feecIe6418, iakovlev.zakhar, Dart-Xeyter, Adam_GS, ShuiLaoshi, golikovnik, Gary2005 за красное тестирование раунда

🐫 NemanjaSo2005, Alexdat2000, Kon567889, tem_shett за оранжевое тестирование раунда

👾 SlavicG, Psychotic_D за фиолетовое тестирование раунда

🐳 C2A, Masha237, ayhan23, Khonshu08, Brahma_tet за синее тестирование раунда

👽 Lord_David за зелёное тестирование раунда

🦄 mejiamejia за помощь с тестерами для раунда

🤡 sevlll777 за задачу, без которой раунд был бы несбалансирован, и задачи, которые не вошли в финальную версию раунда

🎅 MikeMirzayanov за потрясающие платформы Codeforces и Polygon, без которых проведение раунда было бы невозможно ㅤㅤㅤ

Персональные рекомендации

Я искренне надеюсь, что задачи покажутся вам интересными и вы получите удовольствие от их решения. Good luck!

Разбалловка:

500 — 750 — 1250 — 1750 — 2250 — 3000

UPD: Разбор

UPD2: Поздравляем ЧЕМПИОНОВ!

Неофициально:

  1. jiangly

  2. A_G

  3. neal

  4. maspy

  5. turmax

Официально:

  1. satyam343

  2. Sunnatov

  3. RGB_ICPC7

  4. amirhoseinfar1385

  5. vbgladkikh

First AC:

A: nifek

B: AHappyPotato

C: AHappyPotato

D: aryan12

E: lebowski998

F: zihouzhong

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

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

As a tester, I recommend you try every problem.

PS: sevlll777 tried a lot to make a good round for you guys.

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

It isn't at the main page after 7 hours, wow...

As a tester, I'm a little surprised :)

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

Cyan tester?

»
13 месяцев назад, # |
  Проголосовать: нравится -166 Проголосовать: не нравится
✅ Maximize your enjoyment of the contest, not your rating after it

Sounds like a bad round in advance.

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

    After my own participation in this contest, I found your statement wrong.

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

1750 problems are rather rare these days.
Kudos to authors for having them

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

    You know what it means right !!!!!!. It's now time to solve four questions this time. Hahaha

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

I have one rating point left to raise to Specialist, I sincerely hope that I will raise it this round.

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

Since this round is rated for only participants below 2100, I don't see why legendary grandmasters are required for testing.

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

    Legendary grandmasters have more experience than anyone else. They will probably be much better at pointing out things like if a problem has appeared before, if there exists a stupid data structure brute force, if the authors' intended greedy is incorrect and the problem is actually unsolvable, etc.

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

Hopefully my CM contest

I followed the author long time ago because his codes are brilliant and clean so I'm expecting some great problems tomorrow < 3

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

This amount of emojis makes me die inside

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

Ух ты, оригинальный анонс и ранняя разбаловка! Определённо участвую

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

Emoji round

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

How can one become a tester?

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

I am eagerly waiting for this contest...I think I will reach PUPIL by this contest....Let's Hope for the best....I will definitely never give up even I cant make my name green....

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

Early Score Distribution!

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

As a blue tester, best contest I have ever seen!

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

On the behalf of the specialist community i would like to say this time D is 1750. And you lot know what it means right!!

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

As this is my first testing round, I'd like to thank sevlll777 for giving me this opportunity. It was a lot of fun for me.

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

As this is my first testing round, I'd like to thank sevlll777 for giving me this opportunity. It was a lot of fun for me.

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

In div2 contest!

me BEFORE CONTEST
me AFTER CONTEST is over!
»
13 месяцев назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

Wishing all the best to everyone,

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

Participants with a higher rating are invited to participate in the round unofficialy.

Should be:

Participants with a higher rating are invited to participate in the round unofficially.

Update:Fixed.

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

    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⣀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣴⣞⠉⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⢑⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⣿⣿⣿⣿⣿⣶⣤⣀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⢀⣤⣴⣤⣤⣤⣤⣤⣤⣤⣤⣤⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣥⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣽⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣄ ⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋ ⠀⠀⠀⢹⣿⣿⣿⠛⠛⠛⠛⠛⠛⠛⢛⣛⣻⣟⣛⠛⠛⠛⠛⠛⠛⠛⢻⣿⣿⣿⣿⡟⠛⠛⠛⠛⠛⠛⠛⢛⣛⣿⣛⣛⠛⠛⠛⠛⠛⠛⠛⠛⣿⣿⣿⡏⠀⠀ ⠀⠀⠀⢘⣿⣿⣿⡀⠀⣠⠋⠉⣣⠾⣿⣿⣿⣿⣿⡟⠢⡀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⠀⠀⠀⢠⠊⡩⢿⣿⣿⡀⠀⠀⠙⢦⡀⠀⠂⠀⠀⢸⣿⣿⣿⠀⠀⠀ ⠀⠀⠀⠀⢿⣿⣿⡇⠀⣇⠀⢰⣹⢁⣿⣿⣿⣿⣿⣿⣀⢹⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣇⠀⠀⣇⡼⠁⣸⣿⣿⣷⣥⣀⠀⠀⢱⠀⠀⠀⠀⣾⣿⣿⡇⠀⠀⠀ ⠀⠀⠀⠀⢸⣿⣿⣷⠀⠈⠒⢺⣧⣼⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⡀⠀⠈⣷⣿⣿⣿⣿⣿⣿⣿⣆⠀⢸⠀⠀⠀⢀⣿⣿⣿⠆⠀⠀⠀ ⠀⠀⠀⠀⠈⣿⣿⣿⣔⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣧⠏⠀⠀⠀⣼⣿⣿⡿⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⢹⣿⣿⣿⣦⡠⠀⠀⠛⢿⣿⣿⣿⣿⡿⠋⠀⠀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠁⠘⢿⣿⣿⣿⣿⣿⠟⠁⠀⠀⢀⣼⣿⣿⡿⠃⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣶⣤⣤⣤⣬⣽⣽⣁⣠⣦⣴⣾⣿⣿⣿⣿⣏⢉⣭⣽⣿⣿⣿⣿⣿⣶⣤⣤⣈⣩⣭⣭⣥⣤⣤⣴⣾⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⡏⠙⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣼⡏⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢿⠇⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀⣭⡙⠛⠛⠛⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠛⠛⠛⠛⠛⢛⣟⠛⠉⠁⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠙⠁⠀⠀⠀⠸⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⠀⠀⡸⠿⠀⠀⠀⠀⡏⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⢧⠀⠀⠀⣤⡀⠀⠀⠀⠈⠀⠀⠀⢀⣴⣦⣤⠤⠤⠤⠤⠤⠤⠤⢤⣤⣶⣤⡀⠀⠀⠘⠋⠀⠀⠀⠀⠀⠀⠀⣸⠁⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠈⢇⠀⠐⠙⠃⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⡧⠀⠀⠀⠀⠀⠀⢠⡄⠀⠀⣰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⣇⠀⠀⠀⠀⠀⠀⠀⠀⣼⠋⠉⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⣰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠋⠳⠶⠶⠶⠖⠒⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡜⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠳⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠔⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠲⢤⣠⣀⣀⡀⠀⠀⣀⣠⡀⠀⡀⢀⡀⢀⣀⣦⣤⡾⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡖⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠻⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⠛⠋⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

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

Hope the site will work fine.

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

Hope I'll turn CM soon :(

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

Leetcode went down today during the Weekly Contest. All in on codeforces now

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

As a tester. This is an actually good round. Try every problem.

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

Would it be an AI themed contest? sevlll777

Like Codeforces Round 770 (Div. 2)

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

Specialist day, I hope

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

hope rating++

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

NEW ICONS!!! Oh, wait....

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

When I am trying to login via my main account it says user is disabled by administrator? What does it mean? Is it a ban and if yes for how long or is it a bug? Like my main account wasn't being plagiarized too in recent rounds? Please do help.

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

    Please someone do help .I even registered from that account around 20 hours ago .Please help

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

      Please do look into the matter please MikeMirzayanov I have also sent you a personal message regarding this matter please do give it a read please

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

I think, C problem 3rd test case output is wrong. pack 1 and pack 5 can have same price tag.

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

    Yeah I also initially misunderstood the question wrong so that you can change the order of the candy types. Fortunately they then clarified.

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

    Price tags can only cover adjacent equal values. 1 and 5 are not adjacent.

    Even in the example the values reached are [4,4,2,4,4] and the answer is 3 not 2

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

Swap(C,D)

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

I literally took 3mins to solve D after reading it , & couldn't solve C , lol.

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

D<<<C

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

Who else facepalmed when they saw the announcement reminding the condition that the price tags have to be continuous?

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

Ok, I obviously don't get it:)
What so obvious easy was about C and D?

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

My brute force solution passed the pretest of E. Weak pretest. Hope it will get FST.

Update: My solution passed system test. Weak system test. I'll uphack my solution later.

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

Anyone else thought that you can change the order of types of candies on the shelf? I wasted too much time on that :(

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

So how to solve problem D?

Construction is so hard. :(

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

    Just greedy in a somewhat stupid way. It is easy to find this way but it is not instantly obvious why it works.

    • »
      »
      »
      13 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится
      while(i<pos.size()&&j<neg.size())
      		{
      			if (ok==0)
      			{
      				int res=0;
      				while(j<neg.size()&&sum>=0&&abs(res+neg[j])<k) ans[++cnt]=neg[j],sum+=neg[j],res+=neg[j],j++;
      				ok^=1;
      			}
      			else
      			{
      				int res=0;
      				while(i<pos.size()&&sum<=0&&abs(res+pos[i])<k) ans[++cnt]=pos[i],sum+=pos[i],res+=pos[i],i++;
      				ok^=1;
      			}
      		}
      

      It is my greedy... But wrong at pretest 2...

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

        Sorry, I did not read your code but my solution was:

        First, split array to pos and neg. Also calculate number of zeros.

        Then this greedy

          ll ssum = 0, p0 = 0, p1 = 0;
          while(p0 < sz(pos) && p1 < sz(neg)) {
            if (ssum + pos[p0] < MAX) {
              ssum += pos[p0];
         
              cout << pos[p0] << ' ';
              p0++;
            } else {
              ssum += neg[p1];
         
              cout << neg[p1] << ' ';
              p1++;
            }
          }
         
          while(p0 < sz(pos)) {
            cout << pos[p0++] << ' ';
          }
          while(p1 < sz(neg)) {
            cout << neg[p1++] << ' ';
          }
          rep(i, 0, zeros) {
            cout << "0 ";
          }
        
      • »
        »
        »
        »
        13 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Input can be all zeros.

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

          oh yes, sorry, also check if is there any non-zero elements first. But I think if you don't do it you will get WA on the sample.

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

      Pretty sure it was something about Kadane's algorithm but I got too cought up in c too much

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

        So what is Kadane's algorithm?

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

          Basically a greedy algorithm that lets you find the maximum sum subarray when negative numbers are present. You keep a current score and iterate through the full array while also keeping the max score somewhere. If a number is positive, you take it and add it cause it makes score better. If there is a negative number you have 2 cases. Case one is if the score would be negative then you simply set score to 0 (because taking the number would be worse than having nothing) case 2 is if the score after adding the number would be more than zero, in that case you just add it to the score because it might be worth it later

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

          It gives the maximum sum among all of the subarray from an array.

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

    If every element is equal to zero -> no answer.

    Otherwise, group elements in two vectors: positive+zero and negative.

    You build the final array as follows: Keep a variable sum denoting the sum of all elements used up to this point.

    if sum > 0 you append the next negative value to the final array

    if sum =< 0 you append the next positive or zero to the final array

    Largest absolute value of a subarray sum is the largest absolute difference between any two prefix sums. Let max equal the largest value and let min equal the smallest value of the array. You can notice that if currently sum > 0, the next prefix sum will satisfy sum > min and if currently sum <= 0, the next prefix sum will satisfy sum <= max. This means that all prefix sums satisfy min < sum <= max. The largest possible prefix sum is thus max and the smallest possible is min + 1. The absolute difference of these is less than max - min which satisfies the problem statement.

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

      Can u tell what's wrong in my approach: What I am doing is just instead of 0, I am storing max(A) — min(A) into a variable r, then whenever abs(sum of elements + new_element) > r, then start storing elements of opposite sign and so on

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

        The maximum value of prefix sum in your case is going to be r — 1 while the minimum value of prefix sum will be -r + 1.

        The difference between both will be greater than r, which means there might be some subarray that will exceed the allowed sum r.

        I don't know how you implement it but yeah seems like this will definitely fail.

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

    Thanks all above :)

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

Was there any specific tricky case in E? I think I had an almost correct solution (with precalculation of how many correct tests we will have starting from position i using dp with memoization and maximums on suffix on result of this dp) but I have always got WA 3 :(

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

"Shocking Arrangement" is the title of problem D. Yes, indeed.

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

Did anyone else FST B on test 6?

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

Can anyone explain how they quickly proved D? I thought about the correct greedy solution but couldn't prove it.

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

    Copied fom my previous comment:

    If every element is equal to zero -> no answer (trivial to prove).

    Otherwise, group elements in two vectors: positive+zero and negative.

    You build the final array as follows: Keep a variable sum denoting the sum of all elements used up to this point.

    if sum > 0 you append the next negative value to the final array

    if sum =< 0 you append the next positive or zero to the final array

    Largest absolute value of a subarray sum is the largest absolute difference between any two prefix sums. Let max equal the largest value and let min equal the smallest value of the array. You can notice that if currently sum > 0, the next prefix sum will satisfy sum > min and if currently sum <= 0, the next prefix sum will satisfy sum <= max. This means that all prefix sums satisfy min < sum <= max. The largest possible prefix sum is thus max and the smallest possible is min + 1. The absolute difference of these is less than max - min which satisfies the problem statement.

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

      " if sum > 0 you append the next negative value to the final array "

      What if next negative value is not available? And then only positive values are there? The sum might cross mx-mn

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

        It is guranteed that the sum of the whole array is 0.

        If currently sum > 0, we know that for the remaining elements sum < 0. This means that there must be at least one negative element left.

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

    I didn't lol. It just kinda made sense :/

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

I am not sure if this is the solution for F (didn't implement on time) but it rests on this key claim which I cant really prove or disprove: If I have a class of size k and I have at least 2*k-1 bags, I can always find a knapsack of size k divisible by k.

Suppose this is true, then its always possible and I can just take knapsack from small to big. Can anyone prove or disprove the claim?

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

My solution on C 199304839 gets TL7. I have no idea how to speed up it (without writing more optimal solution).

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

    You don't need factorization at all.

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

      I know, but I want to submit this solution.

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

        I think that it's pretty much impossible because the solution would be n*sqrt(1000000000) worst case (each ai is close to 1000000000) and since you have to do modulo it's not possible to push it that far with dirty tricks

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

          Factorization works in O(n ^ (1 / 3) * log n)

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

            Oh, that's my bad for some reason I was thinking about getting the divisors rather than factorization. But, correct me if I'm wrong, let's say you have a perfect square of a prime number isn't the factorization just sqrt(n) then

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

              In my solution I get all divisors. Number of them is O(n^(1/3)) and log from sorting

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

                Have to admit, your code is a bit confusing cause I have never seen recusrive factorization before. How exactly does recursive factorization avoid an sqrt(n) worst case?

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

        If you are interested, I have solved this problem with factorization + dynamic programming during the contest.

        My fresh 1762 ms submission after the contest

        My 2074 ms submission during the contest

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

Anyone knows why my submission for E is wrong?

https://codeforces.com/contest/1798/submission/199302004

My algorithm:

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

    Take a look at Ticket 16777 from CF Stress for a counter example.

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

very hard problemset

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

So big gaps between B and C...

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

very hard problems

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

Amazing round! Really cool problems.

Screencast with commentary

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

what was the proof for problem D ..

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

    depend on your algorithm :)

    for "sort pos & |neg|, take pos and when possible take neg such that sum >= 0" consider situation when sum become too big, easy to see that it is impossible, because prev sum is at least (cur_sum — max) which is greater than |min|, therefore we could use min instead of some pos number now

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

Why is D in this position?

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

Problems were really hard. D was easier than C and C was hell of a hard problem (I understand that C was lcm and gcd, but you still had to think how to fit this operations into problem, which was not an easy task).

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

Great contest, but I personally found D easier than C. Anyone share the same thought?

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

A: For 1<=i<=n-1 check for every pair of (a[i], b[i]) if one of the following is true: (a[i]<=a[n] && b[i]<=b[n]) or (b[i]<=a[n] && a[i]<=b[n]), which is equivalent to min(a[i], b[i])<=min(a[n], b[n]) && max(a[i], b[i])<=max(a[n], b[n]).

B: Check participants reversely. We need to maintain a set of participants in the future, and from today's participants we need to find a participant which is not in the set.

C: The equivalent condition of "we can use same price tag for [L, R]" is gcd(a[L]*b[L], a[L+1]*b[L+1], ..., a[R]*b[R]) % lcm(b[L], b[L+1], ..., b[R])==0. Thus we can solve by dp: let i be the minimum index that we can use same price tag for [i, j], we let dp[j]=dp[i-1]+1. We can find such i by binary search, and we need to process range query by some data structures like sparse table.

  • Note that lcm(b[L], b[L+1], ..., b[R]) could be very large. But since the condition we check need it to be less that max(a[i])*max(b[i])=10^13, we can regard all large values as 10^13+1.

D: If all of a[i] is zero, there's no solution. Otherwise, we can ignore zeros (since they don't contribute to sum of subarrays and can be placed everywhere) and maintain the current prefix-sum. If sum<=0 we append a positive number to the array, otherwise we append a negative number until we used all numbers. Because the total sum is zero, we always have unused number with the sign we want, and every prefix-sum of the array we build is in the range [-min+1, max].

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

    C can be done with greedy. Just greedily include the next candy in the same group if gcd of all ai*bi is a multiple of lcm of all bi. This can be proven.

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
___,,___
                            ,d8888888888b,_
                        _,d889'        8888b,
                    _,d8888'          8888888b,
                _,d8889'           888888888888b,_
            _,d8889'             888888889'688888, /b
        _,d8889'               88888889'     `6888d 6,_
     ,d88886'              _d888889'           ,8d  b888b,  d\
   ,d889'888,             d8889'               8d   9888888Y  )
 ,d889'   `88,          ,d88'                 d8    `,88aa88 9
d889'      `88,        ,88'                   `8b     )88a88'

d88' 88 ,88 888b,_ d888888 d89 88, 88 d888b 88_ 8888 88 88b 88 d888888 8: (6) 88') 88 8888b, 88 d888aaa8888, 'Y' 88b ,888888888888 d88aa88888b ,d8 88b ,8888688888888 d88a d8a88` 8/ q8b ,88'888888'"88 d8b d8888, 88/ 9)_6 88 ,88" 88 88p88 d88888888888bd8( Z~/ 88b 8p 88 68' 88 88888888'688889 88 8 8 8,88 888 8888,qp' 8 8, q 8b88 88" 888b q8 8b "8888888' "888 `q88b "888'

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

I proof by AC-d problem D lol

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

One of the best contest !

In Problem C, One fine observation can convert Binary Search Solution to Linear Solution.

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

Hello, may I ask why my D get punished while submitting again after AC

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

    That is how codeforces rules work. The following is taken from here:

    If a contestant submits several times a problem's solution that passes all pretests, then the last solution is considered as the contestant's verified solution for this problem. All other solutions will be considered as unsuccessful attempts.

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

Why does the pretset data of D not have 3e5 so I got fst?

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

Why does the pretset data of D not have 3e5 so I got fst?

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

Can someone please help explain why my code doesn't work for C? I spent over an hour debugging but it still doesn't pass the first test case.

https://codeforces.com/contest/1798/submission/199296745

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

    You literally have everything correct except for redefining R inside the loop once again...

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

      Oh wait you're right. Bruh this pisses me off so much, if I just fixed that I could've gotten C an hour in.

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

D was wayyy easier than C.

I feel dumb for not taking the 2nd suggestion seriously TwT
»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

D got FST(RE) because of the weak pretest:(

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

    It is not "weak pretest" if you write #define MAXN 200010, but n can be 300000 :)

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

      I've read the guide for problem setting on CodeForces, and it said every problem should have a pretest with maximum input size.

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

      it is my fault but I would have been corrected if the pretest had contained the boundary case

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

Problem D has weak pretest (no testcase with maximum input size)

Problem E has weak system test (allow brute force solutions)

How did they tested this contest

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

    B also doesn't have a pretest containing $$$50000$$$.

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

    Your bruteforce solution of E is non-obvious at all (to come up with). Of course it is my fault and I apologize for this, but it is really unpredictable what kind of solution human brain can come up with.

    For D there is no excuse for me, I thought I had it in pretests and not double-checked it, sorry.

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

Anyone knows why my solution to B is giving TLE?

https://codeforces.com/contest/1798/submission/199298313

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

I came up with a nlogn solution for D but unfortunately could not prove it. Can anybody please take a look? Feel free to hack if it is wrong. I just want to know whether it is correct.

https://codeforces.com/contest/1798/submission/199291200

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

In Problem B I got AC in contest but now it is showing WA on test case 12

Why?

https://codeforces.com/contest/1798/submission/199291886

it seems to be fine for me

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

    oh so Now I got AC so basically have to used long long sum instead of int sum

    but why they didnt show me WA in contest time if this was the issue

    my rating now will be highly affected by this

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

      You didn't get WA during contest because your code is only ran on pretests during a contest. This doesn't include all tests that your solution will be run on after contest, so you can only assume that your solution is probably correct.

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

I solved C with three segment tree and didn't solve D. These turn out that I don't have brain.

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

    what was your approach for C?

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

      First, consider when $$$c_l=c_{l+1}=\cdots = c_{r}$$$. The optimal $$$d$$$ is $$$d_i = \dfrac{\text{lcm}(b_l,b_{l+1},\cdots,b_r)}{b_i}$$$(according to the definition of $$$\text{lcm}$$$). Then if $$$\forall l \le i \le r ,d_i | a_i$$$, it meets the condition. Let $$$l=\text{lcm}(b_l,b_{l+1},\cdots,b_r)$$$. $$$\forall l \le i \le r ,\dfrac{\text{lcm}(b_l,b_{l+1},\cdots,b_r)}{b_i} | a_i \iff \forall l \le i \le r ,\dfrac{l}{b_i} | a_i \iff \forall l \le i \le r ,l | a_i \cdot b_i \iff l | \gcd(a_l \cdot b_l,a_{l+1} \cdot b_{l+1}, \cdots , a_r \cdot b_r)$$$. So we can use two segment trees maintain $$$\text{lcm}(b_l,b_{l+1},\cdots,b_r)$$$ and $$$\gcd(a_l \cdot b_l,a_{l+1} \cdot b_{l+1}, \cdots , a_r \cdot b_r)$$$.

      Second, consider how to get the answer. Let $$$dp_i$$$ means the answer of $$$[1,i]$$$. We can use binary search to get the minimum $$$j$$$ that $$$c_j = c_{j+1} = \cdots = c_i$$$. Then $$$dp_i = \min\limits_{k=j}^i dp_{k-1}+1$$$. We can use another segment tree to maintain the minimum $$$dp_i$$$ in a range.

      Finally, $$$dp_n$$$ is the answer. (Sorry to my poor English and expression)

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

Though C is too hard for it's position, CD are great and E is very beautiful! Thanks for the problemset!

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

.

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

✅ Maximize your enjoyment of the contest, not your rating after it

Agree, 100% (delta=-100), absolutely loved C! I guess problems C and D could have been swapped. Although that probably would've given away the solution to the current D, if it were C.

Thanks again for the amazing contest!

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

https://codeforces.com/contest/1798/submission/199273765

Can someone explain why this solution got runtime error on c?

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

https://codeforces.com/contest/1798/submission/199317662

Can someone explain why this solution of c got a runtime error?

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

satyam343 orz comment. Satyam is a legendary grandmaster in disguise.

He is the women's pet, men's regret and if you bet against him, it is a bad bet.

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

Good contest! Finally reached specialist

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

Well at least i solved C alone, although it was after round ended.

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

Can anyone tell me why in Problem D they said that the sum of all elements is $$$0$$$? The way I proved my solution didn't use this fact at all.

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

    could you please share your idea? I didn't gave much attention to the first line during contest so i failed to come up with a construction, I only know(not sure if true though) that a construction will always exist if abs(sum(all elements)) < max. — min.

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

A great contest,problems are interesting and educational!

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

Finally became specialist... Codeforces Round 860 (Div. 2) was great overall

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

Your solution 199301914 for the problem 1798C significantly coincides with solutions Ultraspeedforces2/199298118, madhurgupta185/199301914. My ratings of this contest have been reverted back. It was a simple problem. Why would I take code from someone who is a newbie.I have been using the same template for a long time. Please look into the matter and take necessary action. Please do look into the matter MikeMirzayanov