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

Автор Wind_Eagle, история, 4 года назад, По-русски

38-20230104210158

Привет, Codeforces!

Я очень рад пригласить вас на Codeforces Round #843 (Div. 2), который пройдет в Jan/10/2023 14:15 (Moscow time). Этот раунд будет рейтинговым для участников, чей рейтинг ниже, чем 2100.

Моя искренняя благодарность:

У вас будет 2.5 часа на решение 6 задач, одна из которых будет разбита на простую и сложную версии. Раунд основан на задачах первого тура третьего этапа республиканской олимпиады по информатике в Беларуси. Просьба всех белорусских школьников, участвовавших в третьем этапе, воздержаться от участия в раунде и обсуждения задач публично до конца раунда.

Я надеюсь, вам понравится раунд!

Тестировали раунд: MathBoy, FairyWinx, nnv-nick, K1ppy, olya.masaeva, Septimelon, PavelKorchagin, 4qqqq, kova1.

Разбалловка: (500+1000)-1000-1500-2000-2000-2500.

UPD. Разбалловка была изменена: (500+500)-1000-1500-2000-2250-3000.

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

Победители

Проголосуйте за вашу любимую задачу!

Задача А: Садовник и капибары

Задача B: Садовник и массив

Задача C: Интересный ряд

Задача D: Дружелюбные пауки

Задача E: Уравнивание людей

Задача F: Лаборатория на Плутоне

UPD3: Наконец-то готов разбор: тык сюда

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

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

omg subtasks for A round

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

I wish Belarusian students good luck on Belarusian Regional Olympiad.

I hope tasks will be interesting for you :)

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

Thanks for inviting


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

Please no more problems like edu 141B

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

could u try to post a blog about this server recently i got to know about this server where mass copiying happens https://discord.gg/6RskCNmG

»
4 года назад, скрыть # |
 
Проголосовать: нравится -33 Проголосовать: не нравится

could u post a blog about this server i recently got to know about this where mass copiying is happening https://discord.gg/6RskCNmG

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

As a tester, I'd like to say that problems are interesting imo and I recommend you to participate!

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

hope this time problem statement is clear :/

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

First time see a problem A with hard version

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

WOW Problem A 1500 point

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

long time since A had a subtask

now could you imagine if it was interactive as well :D

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

Omg! Yellow round.

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

So it seems like from the score distribution, the whole problem A has the same difficulty as B right?

»
4 года назад, скрыть # |
 
Проголосовать: нравится -24 Проголосовать: не нравится

Dont include Mathematical Problems please.

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

Will this contest be as beauty-full as the last one.XD.

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

Finally a contest with friendly time to Chinese coders! Gl, hf!

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

Div2 A with subtasks? Sounds interesting,but I don't know if it will be a good problem.

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

OMG unusual starting time and subtasks for A!! Wish you positive delta!!

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

Finally, the opportunity presents itself. I will become a newbie again.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -77 Проголосовать: не нравится

Hello can you upvote me to help me with my contribution.

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

Plan to take part in this contest. Hope $$$\Delta \gt 0$$$ for me, and you too!

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

NOTE THE UNUSUAL TIME

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

Why some hacks are still in queue.

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

wow

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

OMG, subtasks in problem A!

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

My GPA is crying out

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

8 pm is best time . We have classes at college .

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

Hope it will be a wonderful contest with fantastic problems!

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

As a Chinese,I usually have to stay up late for the cf round, but today I can go to bed earlier, so enjoy it and have fun!

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

I suggest to do more A , B subtasks in the future

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

orz 244mhq

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

Why Delay 10 min Sir ??

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

 

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

Contest start time changed?

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

10 min. delay!

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

DelayForces

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

Now it's delay-master-forces.

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

Will there be second delay if the rating update of last contest still uncompleted?

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

Чёт так жалко белорусских школьников стало.

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

I love this world.

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

Love this contest! As I expected from CF Round #741's author.

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

F is 100491E - Expedition to Mars on higher constraints but it's possible to adjust the intended solution to 4e5.

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

    Actually, I agree with you it's just a matter of time to solve this version if you have a solution for that gym problem and 144 participants solved that problem already I guess so it's easy for them.

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

      Tbf $$$n$$$ up to $$$500$$$ allows a lot more different approaches. When my team and I were solving that gym contest, we went for a solution that isn't really viable for $$$4 \cdot 10^5$$$. Well, at least I failed to fix it :(

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

The most balanced contest

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

I kinda feel bad for spiders with one leg(

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

For C when i run the code in my system it was giving correct output for testcase 1 , but its giving wrong output when run on codeforces for testcase 1 . Any Idea why so ? https://codeforces.me/contest/1775/submission/188754539

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

Nice problemset..

How to solve C?

  • »
    »
    4 года назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +9 Проголосовать: не нравится
    • If $$$x = n$$$, the answer is trivially $$$n$$$ itself.

    • If $$$x = 0$$$, this means that the most significant bit of $$$n$$$ must become 0 at some point. If this is the $$$a$$$-th bit from the right, then the first number to flip this bit is $$$2^a$$$ (single 1 followed by $$$a$$$ 0s). So the AND must include $$$2^a$$$ and we can see that $$$x$$$ AND $$$2^a$$$ is 0, so the answer is $$$2^a$$$.

    • Now $$$x$$$ must have at least one $$$1$$$. Find the last $$$1$$$ in $$$x$$$, and let's say it's at position $$$\ell$$$. Because bit $$$\ell$$$ is a 1, this means it was never flipped while incrementing the numbers, suggesting that all bits to the left of bit $$$\ell$$$ remain unchanged. So the prefix of $$$x$$$ up to bit $$$\ell$$$ must be equal to the prefix of $$$n$$$ up to bit $$$\ell$$$. If there is a mismatch, the answer is $$$-1$$$.

    • We can now write $$$x$$$ as some $$$prefix$$$ (which ends with a 1) followed by all 0s, and $$$n$$$ as the same $$$prefix$$$ followed by some $$$suffix$$$ (whose length matches the block of 0s at the end of $$$x$$$). There are two further cases to consider:

    1. If the $$$suffix$$$ begins with a 1, then we have a problem. Since this bit is 0 in $$$x$$$, it must be flipped at some point. But flipping this 1 will also flip the 1 to its left, i.e., the last bit of the $$$prefix$$$. But we know that the $$$prefix$$$ cannot change, so this scenario cannot happen, i.e., answer is $$$-1$$$.

    2. Otherwise, find the first 1 in the $$$suffix$$$. Let's say it's in position $$$c$$$ (from the right). This bit is 0 in $$$x$$$, so it must be flipped at some point. When this bit is first flipped, the bit at its immediate left (position $$$c + 1$$$) becomes 1, and everything after it becomes 0. This number is $$$x + 2^{c + 1}$$$, i.e., the common $$$prefix$$$ followed by all 0s except a 1 in position $$$c + 1$$$. Conveniently, applying AND between this number and $$$n$$$ will already yield $$$x$$$ (the only $$$1$$$ after the prefix is at position $$$c + 1$$$, which is a 0 in $$$n$$$), so this number is the answer.

    My submission: 188732906. I converted the numbers to binary first, and worked from there, converting back when printing the answer (except when the answer was $$$n$$$ or $$$x$$$ itself).

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

      "I converted the numbers to binary first, and worked from there, converting back when printing the answer."

      Conveniently for me, my computer stores numbers as binary internally so I never need to convert back and forth.

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

        lol, yeah, I know I can use bit shifts to process them faster, but binary strings are more readable imo. I don't have enough experience with bit shifting to be confident that I can code the correct solution with lower thinking + typing time.

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

    Answer will always lie between n and INT64MAX and bitwise and from n to k >= bitwise and from n to k+1 therefore you can apply binary search . To find bitwise and from n to k you can search on net and get method easily .

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

"Time limit exceeded on pretest 12"

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

I hate A so much that I mistook subarray for subsequence in B.

OMG I didn't read this in problem A

Spoiler

Problem A-D is interesting.

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

How to solve F?

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

Any idea of B? I've tried many times but always got TLE

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

How to solve E?

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

    Let $$$s_1$$$ be the maximum sum over all subarrays and $$$s_2$$$ be the minimum sum over all subarrays, then the answer is $$$\max(s_1,-s_2)$$$.

    Lower bound

    Clearly you can change the sum of some subarray by at most 1 per operation, so the answer can't be lower than $$$\max(s_1,-s_2)$$$.

    Upper bound

    For simplicity we suppose $$$s_1 \gt -s_2$$$.

    Consider the following rules:

    1. Adjacent positive elements are automatically merged into their sum. (The same for negative elements)

    2. Zeros are automatically removed from the array.

    It can be shown the answer won't change if we apply the rules.

    After merging, we can repeatly try to change every element closer to 0 and apply the rules after each operation. It can be shown it's optimal. The sum of the greatest subarray will always reduce by 1 after each operation. (If we can't at some moment, then it's not the greatest subarray.)

    If the answer is greater than $$$s_1$$$, then there exists a subarray with sum greater than $$$s_1$$$, which is a contradiction.

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

      currently, your comment helps pretty much noone except those who just who want to see a AC and be done with the problem.

      What was the idea? how did you come up with it?

      Errorgorn's solution makes much mose sense in that regards

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

        The intuition is that after each operation, the total sum of the elements changes by $$$-1, 0$$$, or $$$+1$$$. So if the current sum is $$$s$$$, then the answer is at least $$$abs(s)$$$.

        The second thing to note here is that the answer for the whole array is at least the answer for some consecutive subarrays. So the answer is at least the maximum of the absolute value over all subarray sums.

        Seems like this is achievable. But I currently don't have a proof for this. I have solved it using the same approach that errogorn used in the next comment.

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

        Sorry, it's my bad. I've added some details.

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

    We will process elements left to right. When processing some element, we either create new operation or extend some old operation.

    Intuitively, it makes sense that we would not have to using operations to both add and subtract from an element. So a simple $$$O(n)$$$ greedy works.

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

    Think about a sequence of prefix sums and observer how such operation affects this sequence of prefix sums.

    If you analyze carefully enough, then you'll see that one of the operations just adds $$$1$$$ to any subsequence of prefix sums, and the other operations just subtracts $$$1$$$ from any subsequence of prefix sums.

    So, AFAIK you just need $$$\max(0, \max(p_i)) + \max(0, \max(-p_i))$$$ where $$$p_i$$$ is the array of prefix sums.

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

I take back my words, it was a nice round.

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

F: Why did you set two types of questions as one problem? The difficulty levels of the two questions are different, so I think they should be set as separate problems.

A problem of calculating the number of ways was very interesting!!

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

can we use binary search for Problem C? since & is decreasing function, bitwise and of all number from n to m will be higher than x initially. We need to find first position where bitwise and of all number from n to m is x

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

Problem E almost = This Problem

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

    Yes, you are right, sorry for that :(

    It's interesting that the round with the similar problem is also of Belarusian origin, but the authors came up with the idea independently AFAIK, so it's an unfortunate coincidence.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

Very nice contest! Congrats to the authors!

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

lol, img when i got wrong ans on test 15 problem D and it was only 5 minutes left

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

bruh I feel like a total loser, but at least I'm trying and participating lol

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

if i solved a problem correctly in contest and later during contest , by mistake i submit wrong code for that problem then is question point are added or not to my points

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

In problem B, I read "exclusive or" instead of "bitwise or" and was thinking how to find out if the set of sparse binary vectors is linearly independent and why it is Div2.B

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

String consists of letters 'a' and 'b' only :) could have written it in black :)))

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

I think B problem cannot be solved by people who use JAVA because my O (n * k) solution is getting TLE even after using the fastest I/O operations. Link to my Submission :- https://codeforces.me/contest/1775/submission/188733443

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

    Fixed-size frequency array is unsafe, n <= 10e5 so setting up a frequency array for each test case will instantly TLE you. USe map/hashmap because k constraint is guaranteed to be <= 10e5

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

      You are saying that as t <= 10^5, so the freq array of size 2 * 10^5 (max p) will be iniatialized for each t which will give TLE and everytime initializing a fixed length array is not good beacuse there may be a case when max p is very small but still I am iterating till 2 * 10^5 every time which is unnecessary and the reason for TLE. But HashMap will not give TLE beacuse when we initialize a HashMap its initial size is very small due to which it will not give TLE. Right?

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

if i solved a problem correctly in contest and later during contest , by mistake i submit wrong code for that problem then is question points are added or not to my points

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

how to solve problem b??

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

In task A, either the string b is lexicographically not smaller than the strings a and c at the same time, or the string b is lexicographically not greater than the strings a and c at the same time. @authors kindly look into the language

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

didn't read "The string consists of English letters 'a' and 'b' only." this part in A, So I solved it for every character and I had to use Z function for prefix comparison XD

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

Accepted in last 4th sec.

Screenshot-20230110-191726

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

Can't understand why for B:

1
2
3 8 2 2
3 8 3 3

answer is YES?

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

Nice problems. Hope to see more contests like this in the future

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

Will this round be rated for who has reached 2100+ from 2100- in the last educational round?

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

Overlooking "the characters are A or B" from A2 took me 1hr...

I can't proof my solution for A2 (but it's allowed to use A-Z) so please hack it: 188722831

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

    This is actually a correct solution, if I'm not mistaken. For an arbitrary alphabet, if answer exists, then there exists such answer that |b| = 1. You can now solve task by bruteforce in O(n).

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

    I saw the A or B part, but didn't have a very good proof, so I solved it the most stupid way imaginable.

    • thought that the solution will have a border somewhere around the first/last occurrence of A or B
    • literally bruteforced every combination of first A/first B/last A/last B $$$\pm 1$$$
    • prayed for that there cannot be too many combinations where we needed to scan
    • got AC, still have no proof

    submission: 188710406

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

    I also overlook the a or b term which waste my 1.5 hours. And if am not wrong, the sentence which told that specific a or b term in A2 is added later on the contest. I have solved this through an observation that excluding the first and last character, if there exists an a then if I take it as the second word then it remains the smaller or equal the other two word which are the left and right part of the taken second word. If excluding the first and last character, there not exists an a then it should be the occurrences b and if I take those consecutive b as the second word and the first and last character respectively as the first and last word then the second word remains bigger or equal than the first and last word. In such these way, under the constraints of the problem there always exists a valid answer.

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

    Intrestingly, this is the original problem that was given in the olympiad. It took me 1h40m to solve it, and when I saw codeforces standings, I was absolutely shocked by amount of people who solved it that quickly.

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

didn't notice the unusual timing :facepalm:

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

For C when i run the code in my system it was giving correct output for testcase 1 , but its giving wrong output when run on codeforces for testcase 1 . Any Idea why so ? https://codeforces.me/contest/1775/submission/188754539

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

Best ever standing and solved problem C in Div. 2 the first time! But I didn't have any clue of problem B :(

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

Some discussion for E:

The main purpose of operation is to decrease the value of sum(|ai|) (the sum of the absolute values of ai), to achieve this purpose, we need to subtract from positive numbers, and add to negative numbers.

So every time when we choose subsequence, we can assume we always choose it with alternative sign (which like {+a1, -a2, +a3, -a4...} or {-a1, +a2, -a3, +a4...}), because if not, we can remove 2 adjacent element with same sign, and the total change of sum(|ai|) remain the same.

Therefore, we can always choose the longest subsequence with alternative sign. We can regard some consecutive elements with same sime as one element, and regard zeros as not exist. So we can rewrite the initial array as some non-zero numbers with alternative sign, each element represents the sum of a maximal block with same sign.

So we can get the answer: In each step, we do min(|ai|) times of operation, and all |ai| will be decreased by that value, then we remove zeros from the array, and merge adjacent elements with the same sign. However, this naive approach will be O(n^2) and get TLE. How to optimize it? Notice that if we do min(|ai|) times of operation, some elements will become 0, and it's adjacent elements will be in the same "block with same sign" now. So we could store the initial array into a double linked-list, whose node is like (long:value, Node:prev, Node:next, boolean:valid) and put each node in a priority queue. Each time we poll out a valid node from the priority queue, we merge it with node.prev and node.next to get a new node, link it with node.prev.prev and node.next.next, add it to the priority queue, then mark node.prev and node.next as invalid. Then we could get an O(n*log(n)) solution. (Also do not forget check nullity)

Update: Now my submission:188766704 has got AC. Unfortunately, I've not implemented it properly during the contest. Sad!

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

Mmmmmm

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

Mmmmm

Right after the contest :D

»
4 года назад, скрыть # |
 
Проголосовать: нравится -15 Проголосовать: не нравится

Wonderful round with great problems, it seems they all have clean solutions, but require "cute" observations. A2 is harder than E for me though (failed system testing on A2).

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

To problem B: Why is this case no? 1 3 2 1 2 2 3 4 2 5 6

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

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

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

Problem D was nice.

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

very good round. problem are so interesting.

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

I liked the problems themselves, but I have two minor issues with the presentation:

  • For Problem B, the input format was rather unusual, so I think it would have helped immensely if there was an example of a line in the given input format with an indication of what number it represents (preferably in both binary and decimal). As it is, I think the problem looks rather intimidating, despite actually being very simple, especially since participants do not even need to be aware of how to code bit operations to solve this.

  • For Problem C, specifying that the answer is guaranteed to be bounded below $$$5 \cdot 10^{18}$$$ is rather misleading, and notably suggests that a standard 64-bit signed integer type (like long long in C++) is insufficient. However, the actual upper bound is much lower (I think it's $$$2^{60}$$$), so 64-bit signed integer type would actually have been fine. But having the constraints specify $$$5 \cdot 10^{18}$$$ can scare away participants who memorized the upper bound for 64-bit signed integers before they could figure out that the upper bound was highly overestimated or that an unsigned 64-bit type would have worked regardless.

These are minor issues, but I think they serve as obstacles for less-experienced programmers who might otherwise have been able to solve these problems more smoothly, and I don't think early problems like B and C are good places to punish them for these kinds of little details.

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

    The max value of signed int64 is 2^63-1=9.223*10^18, which is definitely larger than 5*10^18.

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

      Oops, sorry, you're right. I was mistaken in thinking that was the unsigned upper bound. That being said, I don't think I'm alone in making such a mistake, so I do still think the overestimated upper bound can be intimidating for many, regardless.

      Most problems I see that involve long long calculations use an upper bound of $$$10^{18}$$$, or (more rarely) $$$2 \cdot 10^{18}$$$ if intermediate values are not expected to overflow. An upper bound of $$$5 \cdot 10^{18}$$$ is quite unusual, especially for a C problem.

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

How to solve C?

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

How to solve D? I tried to construct and graph using prime factors and then apply DFS but got WA.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Is the jiangly's answer corrent for this case of problem A?

1 abcbbc

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

I think this solution 188779455 works in O((log(n))^2) for problem C

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

Hello, Why is this giving TLE?(Solution for B) When I replaced the vector cnt with map, it got accepted Solution for B

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

Hi, Why is this giving tle?...When i replaced vector cnt with map it got accepted Solution for B

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

C can be solved in $$$O(\log n)$$$ without binary search. Here is how.

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

One of the best round! Loved it!

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

Wind_Eagle Hello. Nice round with cool problems. I think the testers happened to miss out on big powers on B despite the pretests on B including big powers some solutions passed due to UB nature of C++.

My solution is pretty straightforward so I feel the testers were just unlucky not to find a possibility of such a FST.

That's my only bit of feedback. D is a nice implementation problem.

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

OMG. I misread B's statement thinking the problem is about XOR even after rereading a couple of times

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

In the first test case, the only possible way to split the line s into three lines is "b", "bb", "a".

I'd been wondering for over half an hour why the first test case has only one solution. I thought I misunderstood the problem and kept on re-reading the description in case I missed something. But then I realized that the statement had been secretly changed...

In the first test case, one of the possible ways to split the line s into three lines is "b", "bb", "a".

I believe it would be better if contestants receive notification after any problem statement change.

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

can anyone tell which test case i am missing here is the link of my code code

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

This was a great round involving interesting bits . No pun intended. I found them interesting and made editorial videos on these, you can check them at this channel- here

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

Still can't believe the implementation of a div2E problem could be as easy as "find the difference of the maximal prefix sum and the minimal" which could be implemented by anybody. What an excellent problem. I just implemented a complicated O(n*log(n)) algorithm and couldn't debug it before the contest ended.

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

A Great Round!

But I failed to become Master as I had promised. : (

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

I have question for problem B

What subsequences are proper for such arrays?

3 1 2 3
3 3 4 5
3 1 4 5

1 1 1 0 0     "2"
1 1 0 0 1     "3"
    1 1 1     "1"

I think it is impossible to find such sequences to obtain the same OR result. This is 7-th token for test 2.

https://codeforces.me/contest/1775/submission/188813071

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

Problem setter was bad. Still they do not add a dislike button for each problem. What a strategy! Shame on you!

Note: Downvotes accepted. Because I want to reveal their actual face!
»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Ah it hurts man!
Its too hard to live with 1399 rating

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

Is the new test data for question D an attempt to get dijkstra stuck?

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

Hardest task A i've ever seen (div2)

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

For problem C, many have used this logic. Can someone explain this logic with proof, and with an example

for(ans=n;ans&&ans!=x;) ans&=n+=n&-n; ans==x?printf("%lld\n",n):printf("-1\n");

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

    For integer x,if x&y ( y < lowbit(x) ). For example, x=101000B, y=100B, m=x&y, the last 3 digits of m have to be 0, it means that the last 3 digits of m won't change. To change the last 4th digit of m, x must be added an integer which is greater than 1000B, and then x=110000B,it can make the last 4th digit of result equal to 0.

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

Where's the solution or editorial?

Thanks!

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

I got a delta of +77 in Educational Round 133 with initial rating of 1333 and rank of 3959.

But I only get a delda of +36 this time with initial rating of 1392 and rank of 2185.

I thought I might get a delta over +100, it's far from my expection :(, and I'm confused.

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

Problem F is about partition number, which need to prepare the partition number up to sqrt(n) (partition number of n is the number of unordered tuples of positive integers (a1, a2, ..., a_k) where sum of a_i is n), and calculate it's 4th convolution power (by doing self-convolution twice). Although the unknown mod number disabled FFT, we can calculate it directly since sqrt(n)<640 is small enough.

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

    Why convolution gives correct result?

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

      Assume that the minimal rectangle contains the rectangle is a*b, we need to remove a*b-n=k blocks and remain the perimeter unchanged. First consider the situation which we only remove from the upper left corner. Let r1,r2,r3… is the number of blocks we'll remove from the 1st, 2nd, 3rd… row. We can observe if the perimeter is remained, r1 >= r2 >= r3… must hold. Thus number of ways to remove k blocks from one corner is p[k] where p is array of partition numbers. If we need to remove from all 4 corners, let for each corner we remove k1, k2, k3, k4 blocks, where 0<=k_i<=k, sum(k_i)=k, the total number of ways to remove k blocks is sum(product(p[k_i])), where {k_i} iterates over all 4-tuples which satisfies the former condition. That's the definition of convolution (the convolution of array a and b is conv(a,b)[n]=sum(a[i]b[n-i]), which is equivalent to sum(a[i]b[j]) where i+j=n).

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

While the problems A-E were nice, problem F blew my mind, huge props to authors! It is the best problem i have solved in 2023 so far. My friend and i spent around 2 school days on this one and we had a blast :).

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

Deleted.