Wind_Eagle's blog

By Wind_Eagle, history, 4 weeks ago, translation, In English

38-20230104210158

Hello, Codeforces!

I am very glad to invite you to the Codeforces Round #843 (Div. 2), which will take place in Jan/10/2023 14:15 (Moscow time). This round will be rated for the participants with rating lower than 2100.

My sincere thanks to:

You will have 2 hours and 30 minutes for solving 6 tasks, one of which will be divided into easy and hard verions. The round is based on the problems from the first day of Belarusian Regional olympiad. We kindly ask all Belarusian pupils who participated in this olympiad, to refrain from taking part in this round and discussing the problems publicly before the round ends.

I hope you will enjoy the round!

Round testers (not complete list): MathBoy, FairyWinx, nnv-nick, K1ppy, olya.masaeva, Septimelon, PavelKorchagin, 4qqqq, kova1.

Score distribution: (500+1000)-1000-1500-2000-2000-2500.

UPD. Score distribution was changed: (500+500)-1000-1500-2000-2250-3000.

UPD2: Congratulations to the winners!

Победители

Vote for your favourite task!

Task А: Gardener and the Capybaras

Task B: Gardener and the Array

Task C: Interesting Sequence

Task D: Friendly Spiders

Task E: The Human Equation

Task F: Laboratory on Pluto

UPD3: Finally, here is the editorial: press here

 
 
 
 
  • Vote: I like it
  • +309
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it +158 Vote: I do not like it

omg subtasks for A round

»
4 weeks ago, # |
Rev. 3   Vote: I like it +20 Vote: I do not like it

I wish Belarusian students good luck on Belarusian Regional Olympiad.

I hope tasks will be interesting for you :)

»
4 weeks ago, # |
  Vote: I like it +15 Vote: I do not like it

Thanks for inviting


»
4 weeks ago, # |
  Vote: I like it -20 Vote: I do not like it

Please no more problems like edu 141B

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    Delete this they will surely give it then

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it -9 Vote: I do not like it

    That's was a good constructive problem. I like those problems because even newbie can solve it and i have seen even master are sometimes not able to solve them. Try till you get the right approach.(It's just how i see them haha).

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it -13 Vote: I do not like it

      Well I literally hate problems like edu 141B and div2 842C. I feel like these problems are all about guessing. The faster you guess the better rank you get

»
4 weeks ago, # |
  Vote: I like it -33 Vote: I do not like it

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 weeks ago, # ^ |
      Vote: I like it +23 Vote: I do not like it

    bruh imagine advertising cheating

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 3   Vote: I like it -11 Vote: I do not like it

      is there anything we could do?

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it +26 Vote: I do not like it

        they will create new accounts after bans anyway, so best we can do is not advertising them

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    i think u can't do anything, but sadly they didn't improve them self

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +2 Vote: I do not like it

hope this time problem statement is clear :/

»
4 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

First time see a problem A with hard version

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Good luck everyone!

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

for the first time i think there would be subtasks for a this is very exciting!

»
4 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

Omg! Yellow round.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

OMG,there are subtask for problem A.

»
4 weeks ago, # |
  Vote: I like it -24 Vote: I do not like it

Dont include Mathematical Problems please.

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Actually, 22:35(UTC+8) is not TOO unfriendly for who are used to staying up late. It's better called friendly time to Australian coders.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    I remember that once there were two contests held at about 15:35(UTC+8) and 18:35(UTC+8) on the same day.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Exactly, very friendly time! Hopefully, this is also a fantastic round!

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Of course it's a very friendly time.I can't stay up late because my father don't allow me to do that:)

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it -6 Vote: I do not like it

    nice

»
4 weeks ago, # |
  Vote: I like it -11 Vote: I do not like it

i give up :(

»
4 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it -12 Vote: I do not like it

harder version? omg with the same rating

»
4 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Unusual time :(

»
4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I hope that this round will be a starting point for me to succeed in the new year 2023 ! And I wish good luck and success to everyone this year.

»
4 weeks ago, # |
  Vote: I like it -77 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

NOTE THE UNUSUAL TIME

»
4 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

wow

»
4 weeks ago, # |
  Vote: I like it +37 Vote: I do not like it

My GPA is crying out

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

Hope it will be a wonderful contest with fantastic problems!

»
4 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Ok so in this round I will not able to do problem A as well (interesting).

»
4 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    True Mate.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it -7 Vote: I do not like it

    After this contest, I have to disagree.

    Problem A2 is scaring me. I wouldn't have participated if I cared about my rating.

»
4 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

orz 244mhq

»
4 weeks ago, # |
  Vote: I like it +35 Vote: I do not like it

Why Delay 10 min Sir ??

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

 

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

Contest start time changed?

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

10 min. delay!

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

DelayForces

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Now it's delay-master-forces.

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I did not understand at all what to do in the task B

»
4 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

I love this world.

»
4 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +14 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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 weeks ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      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 weeks ago, # |
Rev. 3   Vote: I like it -13 Vote: I do not like it

The most balanced contest

»
4 weeks ago, # |
  Vote: I like it +76 Vote: I do not like it

I kinda feel bad for spiders with one leg(

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +86 Vote: I do not like it

    You are not worried about $$$3\cdot10^5$$$-legged spiders, right?

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it +21 Vote: I do not like it

      legend says that spider is still tying his shoelaces.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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.com/contest/1775/submission/188754539

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice problemset..

How to solve C?

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it
    • 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 weeks ago, # ^ |
        Vote: I like it +22 Vote: I do not like it

      "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 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      "bitwise and from n to k >= bitwise and from n to k+1"

      How did u arrive at this property? Can you please explain/elaborate as i am unable to understand.

      • »
        »
        »
        »
        3 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        just try to analyze the truth table of AND.after applying and operator you will realize that, it keeps value as it is or make it decrease.

        1&1=1 0&0=0 value remains as it is in above two cases.

        0&1=0 1&0=0 value decreases in these cases.

»
4 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

"Time limit exceeded on pretest 12"

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    no need to look at one prime number more than once during bfs (this helped me with test 12)

»
4 weeks ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

How to solve F?

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I suspect giant casework.

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 2   Vote: I like it +26 Vote: I do not like it

      Actually, no. The short idea is that all the possible answers are just rectangles with their angles cut somehow. You need to make a DP on how you cut the angles and iterate over the possible rectangles.

      For example, if $$$n=7$$$, then the optimal perimeter is $$$12$$$, and you need to try out the rectangles $$$3\times3$$$, $$$4\times2$$$ and $$$2\times4$$$ and cut their four angles somehow. A cut of an angle is just removing a stair-like figure, so it's calculated with DP.

      • »
        »
        »
        »
        4 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Ah got it, problem seems interesting now!

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it +11 Vote: I do not like it

        The idea is actually obvious, can you tell how to calculate the DP?

        • »
          »
          »
          »
          »
          4 weeks ago, # ^ |
            Vote: I like it +24 Vote: I do not like it

          You may precalculate $$$dp_{n,k}$$$, that is the number of stairs from $$$n$$$ blocks which are $$$k$$$-block tall. This DP can be computed in $$$O(n^2)$$$, but, since the number of blocks to be cut from angles is no more than $$$O(\sqrt n)$$$ in total, it's OK.

          Then, you just need to write another DP which decides on how much blocks to cut from each angle. It's $$$d_{i,j}$$$ where we have decided about the first $$$i$$$ angles and have already cut $$$j$$$ blocks.

          Note that all these DPs can be calculated in the beginning and used to answer all of the testcases.

          • »
            »
            »
            »
            »
            »
            4 weeks ago, # ^ |
              Vote: I like it +11 Vote: I do not like it

            Got it, thanks!

          • »
            »
            »
            »
            »
            »
            4 weeks ago, # ^ |
              Vote: I like it +3 Vote: I do not like it

            But how do you check that the stairs in different angles do not intersect while calculating $$$d_{i, j}$$$?

            • »
              »
              »
              »
              »
              »
              »
              4 weeks ago, # ^ |
                Vote: I like it +13 Vote: I do not like it

              You don't have to check it.

              If they are going to intersect, then the perimeter is just not optimal.

              • »
                »
                »
                »
                »
                »
                »
                »
                4 weeks ago, # ^ |
                  Vote: I like it +5 Vote: I do not like it

                Oh yeah, fair enough. It was the only part I was struggling with and this observation is so easy (( Thanks a lot!!

            • »
              »
              »
              »
              »
              »
              »
              4 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              They will not intersect. Because if it is possible, you can decrease the perimeter of your figure.

»
4 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Also please update the rating of last educational round quickly

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      What I have done, is to count the no of occurrence of a bit throughout the whole array. Then for each element in the array if any bit which is set for this element is also set for any other element, Then the ans is always yes otherwise no

      Let me explain the reason with an example ,consider a no whose bit 2 and 4 is set. Another no whose bit 2,1 and 3 is set and another no whose bit 4, 5 and 7 is set. Since For First No, every bit that is set for this, also set for either b and c, so we can always take Or of every no in the array and Or of every No except that No(First one in this case). In Other words f(a) = Second No | Third No, f(b) = First No | Second No | Third No. Hence Ans is always possible.

      Here is my submission 188728251

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If bits set in one number is a subset of another number , then the answer is always possible.

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 5   Vote: I like it 0 Vote: I do not like it

      what about 4 number {1,2} , {4,3} , {1,3} , {2,4}

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Yes in that case also the answer is possible.

        We need to check for every number if the occurrence of all the bits in this number is > 1. If it is satisfied, then the answer is Yes.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Did you by any chance used a fixed-size frequency array? freq[200001] * n <= 10e5 = TLE... I should know from having fallen for it 5 times this contest.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I've thought Double linked-list and priority-queue could solve E, but got WA.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    when I used vector to store the frequencies I got the TLE, but then changed to unordered_map it passed. not sure why vector[i] is slower than map[i] :(

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      I used int[200001] and got TLE 5 times because I forgot n <= 10e5 so I was doing 200000 operations per test case just setting up a frequency array.

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Two cases:

    1) if second character is ‘a’, then place s[0] s[1] rest

    2) if second character is ‘b’, then place s[0] allCharactersExceptLast s[n-1]

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Hint: the first subsequence is the whole array, the second is the whole array except only one number.

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I've noticed that but my approach got TLE

      It seems that we need to store frequencies by map instead of array

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        You can use array, but it should be global. Furthermore, you should only set the elements you touch to 0, not the full array.

»
4 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

How to solve E?

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it +24 Vote: I do not like it

    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>-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 weeks ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      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 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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 weeks ago, # ^ |
          Vote: I like it +13 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it +21 Vote: I do not like it

    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 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you very much!

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Is there any formal proof? (or an outline of a formal one)

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it +19 Vote: I do not like it
        Yes
  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +24 Vote: I do not like it

    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 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +42 Vote: I do not like it

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 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think subtask 1 is as easy as problem A...

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    You are right probably, it should be split.

    By the way, the original contest is OI-style, so there two problems were combined as one, with different groups for each of the subproblems. For Codeforces, the problem was just retained as-is.

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it +16 Vote: I do not like it

Problem E almost = This Problem

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    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 weeks ago, # |
  Vote: I like it -6 Vote: I do not like it

Very nice contest! Congrats to the authors!

»
4 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +38 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it +43 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it
    Whining
  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Well, I just knew about it know.....

»
4 weeks ago, # |
  Vote: I like it -14 Vote: I do not like it

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.com/contest/1775/submission/188733443

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    change your "int[] freq" to "map freq" and try, it worked for me in c++.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    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 weeks ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

how to solve problem b??

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    hint1
    hint2
»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I can't understand the Input of B :(

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    in problem b n is size of array and n line is given in each line first no is the no of set bit in that number and after that positions of set bit is given

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I still don't get it, but thanks anyway.

      • »
        »
        »
        »
        4 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        The very first number is the number of test cases.

        The first number of each test case (say k) is the number of elements in the array of that case.

        Now k lines of space-separated numbers follow — each line is an element of the array represented in this form: the first number (p) is the count of set bits of that particular element of the array.

        The numbers that appear after p (there are p of them) are the positions of each of the set bits.

        Edit: Essentially, each individual line represents an element in the array.

        • »
          »
          »
          »
          »
          4 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          If a line is 3 1 2 5,the binary number is 10011,to decimalism is 19. In the contest I understand it this way,Is it so?

          • »
            »
            »
            »
            »
            »
            4 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Yes, 3 1 2 5 implies 10011

            • »
              »
              »
              »
              »
              »
              »
              4 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Wow!!

            • »
              »
              »
              »
              »
              »
              »
              4 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              The "Note":In the second test case, one of the possible answers are following subsequences: the subsequence a formed by the element at position 1, and the subsequence b formed by the elements at positions 1 and 2. 2 2 1 2 1 2 This is a array{3,2},but 3 != 3 ^ 2.this is why? Can you tell me? Thanks.

              • »
                »
                »
                »
                »
                »
                »
                »
                4 weeks ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                I don't completely understand your question, but I can explain the second test case:

                2
                2 1 2
                1 2
                

                like you said, this represents the array [3, 2].

                The given solution for this case is that the two subsequences would be [elem_at_pos_1] and [elem_at_pos_1, elem_at_pos_2].

                So the text claims the subsequences would be s1 = [3] and s2 = [3, 2].

                And this is true because the bitwise OR of s1 = 3 (as there's only one number) and the bitwise OR of s2 = 3 | 2, which is also 3. Clearly, they're both equal.

                I think you may have misunderstood the bitwise OR operation to be something else.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  4 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Oh, I see. I mistake bitwise OR as XOR. QwQ My English is not good.I didn't expect to make such a mistake. Thank you very much.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  4 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  No worries, cheers!

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it +62 Vote: I do not like it
  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What IDE/Editor/Plugins do you use for contests?

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

how to solve B? also in C is there any relation between x and m?

»
4 weeks ago, # |
  Vote: I like it +4 Vote: I do not like it

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 weeks ago, # |
Rev. 3   Vote: I like it +32 Vote: I do not like it

Accepted in last 4th sec.

Screenshot-20230110-191726

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can't understand why for B:

1
2
3 8 2 2
3 8 3 3

answer is YES?

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Next follow ki distinct integers pi,1,pi,2,…,pi,ki (1≤pi≤2⋅10e5)

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Ki integers are guaranteed to be distinct

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This input is not valid, since the set bits must be distinct. For example, in the line 3 8 2 2, the given set bits are 8, 2, and 2, which is not a valid input. In the line 3 8 3 3, the given set bits are 8, 3, and 3, which is also not a valid input.

    If you actually meant the following:

    1
    2
    2 8 2
    2 8 3
    

    then the answer is NO.

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

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 weeks ago, # ^ |
    Rev. 2   Vote: I like it +23 Vote: I do not like it

    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 weeks ago, # ^ |
      Vote: I like it -13 Vote: I do not like it

    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 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      And if am not wrong, the sentence which told that specific a or b term in A2 is added later on the contest

      You are wrong and just try to justify yourself.

      • »
        »
        »
        »
        3 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks for the confirmation. It is honor for me to your reply. I don't try to justify myself. Everyone do mistakes. From next I will be aware of this.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve B and C ?

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

didn't notice the unusual timing :facepalm:

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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.com/contest/1775/submission/188754539

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In my system, your submission is giving wrong answer only for the last test case.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You're doing ll rem=(1ll<<i)-(i?pre[i-1]:0); inside a for loop where i can equal 0, meaning you're trying to do pre[-1] which points you to other memory. This is why the code doesn't work or works differently on different machines.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Maybe an overflow is happening. Change LONG_MAX to 1e18+1

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      And don't forget, that in the case of n and x being both zero, your pre will be 0 sized, which gives an error

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      Thanks Bro .I changed LONG_MAX to 1e18 and it worked . But any idea why so ?

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        It seems, that LONG_MAX doesn't work on cf. It returns 2147483647(int_max) on cf, and 9223372036854775807 on onlinegdb. This wasn't an overflow then

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it
    Hint
    Solution
    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      but how are we sure that if we cant remove any element such that or of remaining element is same then answer will not exist?

      • »
        »
        »
        »
        3 weeks ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        If for every number there is a unique bit that only appears into that number than to make the difference in the sequence you need to not take this one. If all the numbers contains a bit that is unique in them you have only two options either take all of them or nothing. To make them different we take both as these are the only options but there OR is not same.

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It seems that we should check every number in array c, if there exists one i, every bit in c[i] appears 2 times in the whole input, then the answer is "YES", otherwise "NO".

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    poor English :( Obviously the maximum set is a1 or a2 or ... or an .So let p is this subsequence.

    To find q, the number of elements in q must be at least 2.In this case, without q the p has no elements left.

»
4 weeks ago, # |
Rev. 7   Vote: I like it 0 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

Mmmmm

Right after the contest :D

»
4 weeks ago, # |
  Vote: I like it -15 Vote: I do not like it

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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
    Rev. 2   Vote: I like it +5 Vote: I do not like it

    But the rating of last educational round has not updated yet! Please update it first! I should have been div1 in this contest......

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Oh, sorry for that, our fault. Will fix soon.

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I might be wrong, but I think whether the contest is rated for you or not depends on which rating you had at the time of registration. Even if the rating for the edu round was updated before this contest but after registration, this contest would still have counted for you.

      In fact, this is why some users deliberately register for as many contests as they're able to when they're close to the border, so that they're all counted even if they cross the border sometime in the middle, e.g., earning Div2 rating boosts even after reaching Div1.

      So regardless of when the ratings are updated, it should not change the fact that this round will be rated for you. In the future, please consider your rating at the time of registration before you decide to register for a contest, since rating changes that were not yet applied would not be considered for the contest you're registering for.

      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Huh, thank God I took this div2 seriously :) Otherwise my M would have lasted less than 24 hours.

»
4 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

Problem D was nice.

»
4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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 weeks ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

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

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve C?

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    DFS ? I think you mean BFS

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Use BFS to get the shortest path. DFS is not for shortest paths.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I believe dfs (or DP) can be only used for Directed Acyclic graphs to find shortest path between nodes. anyone correct me if I'm wrong.

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Actually both are used to find the shortest path in DAG. First using DFS for finding the topological sort and then according to topological sort apply the dp.

»
4 weeks ago, # |
  Vote: I like it -8 Vote: I do not like it

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

1 abcbbc

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The string only contains letters 'a' and 'b'.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The string only consists of "a" and "b".

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    String consists only of letters 'a' and 'b'.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The string consists of English letters 'a' and 'b' only.it is mentioned in problem statement.

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I wasted 10-15 minutes because of not reading this carefully.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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