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

Автор _LeMur_, 5 месяцев назад, По-английски

Hi, Codeforces!

I'm glad to invite you to take part in Codeforces Round 917, which will take place on Dec/24/2023 17:35 (Moscow time). Round will be rated for participants with rating less than $$$2100$$$. Participants from the first division can take part out of competition.

There will be $$$6$$$ problems for $$$2$$$ hours. The problems are authored by IgorI, zidder and me.

Part of the problems in this round were in the Yerevan SU 28.1₀.₂₀₂3 Contest. If you participated in it or know at least one problem from it, please refrain from participating in this round.

We would like to thank

Scoring distribution: $$$500 - 1000 - 1500 - 2250 - 2500 - 3000$$$

We hope you'll like the problemset! Good luck and have fun!

UPD 1: Editorial

UPD 2: Congrats to our winners:

  • Div1 + Div2
  1. tourist
  2. Sugar_fan
  3. BurnedChicken
  4. Rubikun
  5. kotatsugame
  • Div2
  1. -Misaka-Mikoto-
  2. _chashuibiao_
  3. needy_and_sorry
  4. Godjob
  5. LordVoIdebug
  • Проголосовать: нравится
  • +281
  • Проголосовать: не нравится

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

]

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

Great!!!

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

As a tester, I recommend trying all of the problems (really good ones). Also I wish everyone positive delta as a Christmas present:)

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

I will try it!

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

^_^

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

As a tester, I want to reach pupil after this round

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

Looking like speedforces:( because D is 2250.

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

hgglmao This round is good?

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

i hope i become expert after this round

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

CM TIME

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

participate cf contest on Christmas Eve (east Asia time) this is really a round 😂

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

Big point difference between C and D

»
5 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится
╱|、
                      (˚ˎ 。7  
                       |、˜〵          
                      じしˍ,)ノ
»
5 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Hopefully I become a master after this contest!

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

Maybe I can reach specialist by the end of this year :)

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

    Mate you just missed by 2. Maybe in rechecking later it may increase.......

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

      Yeah, was almost there... maybe next time

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

      And I'm confused how the hell on earth did your code for problem C got accepted...I just copied and ran your code and it's showing WA on testcase 38

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

        Can you tell me what did you change to get it accepted?

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

          Just ran the outer loop till d rather than min(d,max(n,k) and then checked inside the loop if n+(d-i-1)/2<=current_answer then simply break as checking beyond it wont give the maximum answer. Because the max n can go upto is 2000 where as d can go till 1e9.

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

As a tester for the 1st time,i feel proud.

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

Specialist Time ! I hope .

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

yeeeeeey

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

Yo

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

Hope to become Expert.

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

hope is a good thing

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

I will finally give a Cf contest. Lets go.

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

As a contestant,I want to reach pupil after this round btw

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

best wishes for every one

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

Clicked me now, why all are LGM here

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

As a kawazaki I will participate

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

AbduSaber First tester from Sohag, Egypt :) , remember this name very well -_- .

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

Hope to solve all the problems!

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

As someone who has a birthday, please give me a contribution.

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

Really weak sample for C. Is it fun to see players wa2 again and again?

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

my last unrated contest

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

Hope will become expert

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

unbalanced forces !

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

Спасибо за испорченное преднавогоднее настроение! Один из самых неудачных наборов задач для див2, который только можно представить

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

Defeated by constructive round. so sad.

update: now I'm defeated by the FST XD

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

Am I missing something or does D effectively boil down to:

  • Calculate inversions within P.
  • For each i, calculate number of values in P which would be its inversion for relative power shifts between -20 to 20.
  • Iterate over values of Q, and check how many occurances of [Q_i — 20, Q_i + 20] lie before it and add them to the answer.

I spent 15-20 mins thinking of how to simplify this to something I could implement without going insane before giving up and going to problem E instead...

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

    Had the same idea, how are you calculating the inversions for relative power shifts? My approach ended up double counting many things

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

      I didn't implement it because I felt it would be an utter mess. As I mentioned I just gave up and went to solve E instead.

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

    You don't need to simplify this to anything else. You can calculate this directly

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

      I mean "simplify" the implementation so I don't go insane implementing this. I seriously doubt I could code this in less than an hour with all the debugging from minor mistakes that are likely to occur. It feels like a 10 mins to think, 1 hour to code problem.

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

    Can u plz explain me your submission for problem B, why it is working ?

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

Whoever made C deserves lifetime sentence in jail.

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

How to approach B?

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

    Sum of the first occurrence of each character is the answer. Suppose we have s = "abeakf". Then if we consider 'a' is the first character, we will have ["abeakf", "aeakf", "aakf", "akf", "af", "a"]. We only need to care about the first position of character 'a' in s, because if we tried to used the second 'a', the result string will be duplicated (these are "akf", "af", "a")

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

    Essentially, the only difference between strings after "i" operations is the first letter. That's because you can't reach the other characters through these operations. However, that initial letter could be any letter present in the prefix of length "i" of the original string. So, you calculate the number of unique letters in each prefix and then sum them up. That's basically the answer.

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

    Just add the left over length when ever you encounter a new character. for a string abcde the number of substring contributed by letter 'a' => $$$a, ab, abc, abcd, abcde = 5$$$, 'b' = 4... so on.

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

    check the string from left to right, if i th character has not appeared before, answer += n-i

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

    I thought of that in this way. Suppose you have a string "ayush",now if you want to find all the strings of size '4', "ush" will always be there so the string will be "_ush" now for the first character look at how many distinct characters we have encountered before we reach 'u' (2), so there are two possible choices for the first character. Do this starting from size 'n' to size '1'. Hope this makes sense to you!

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

still don't know why in C, when I tried to iterate min(n, d) times, it gave me wrong answer, since I thought it is enough to make the array big. I used a large number instead like min(5000, d) and got AC.

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

    i did min(3*n, d)

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

      why?? can you explain why calculations after 2*n/3*n will be waste??

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

        Suppose we have:

        A = [N, 1, 2, ..., N-1]
        V = [1] * (2N-5) + [N]
        

        Then after (2N-5) + 1 operation (1), we have:

        A = [3N-4, 2, 3, ..., N]
        

        where 3N-4 = N + (2N-5) + 1.

        Apply operation (2) to score N-1 in (2N-4) + 1 = 2*(N-2) + 1 < 2*(N-1) which beats the alternating method from the zero array.

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

          This seems much like a case specific example. How can you guarantee that the claim is true for any A and V ?

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

            All the calculations from an initial array A only result in a single scoring operation before it gets reset to zero.

            As stated in the comment below, the largest score we can get from a single scoring operation is N — assuming every element satisfies the criterion.

            Calculations taking strictly more than 2N moves are not better than scoring immediately (ie. transition to zero array; if needed) and then alternating operations 1 and 2, scoring N.

            I produced the earlier example to show that in some case, we cannot perform much fewer than 2N moves either.

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

              Oh, I get it now. Thank you so much.

              UPD: I would like to explain mathematically (that's how I like to go about it). Let's say you have done operation 1 for the first $$$X$$$ days, and for the rest $$$(D-X)$$$ days, you'll perform both operations alternately. So your total score would be $$$S + (D-X)/2$$$ where S is atmost N. If you had performed alternating operations from the start, you would have scored $$$D/2$$$. Now, my prior answer is better only if:

              $$$\frac{D}{2} < S + \frac{D-X}{2}$$$
              $$$\Rightarrow X < 2*S$$$

              Hence, you will get the most optimal answer in the first 2N days because S could be atmost N.

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

                You can't get $$$d/2$$$ in general case because if you start alternating ops from day 1 you'll get $$$initialScore + (d-1)/2$$$. Proof: 238854323

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

          oh I got it, we want to maximize the answer, so one possible answer can be d/2, via doing reset and cash score operations. but to further optimize our answer, we will be checking first at least 2*n days and check whether we can score of n-1 in these days or not. if we can that would give us maximum possible score.

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

    $$$n$$$ is not sufficient. You can raise the answer by $$$1$$$ in $$$2$$$ steps using operation 2 but operation 1 can add upto $$$n$$$, so you need to check for the first $$$2 \cdot n$$$ steps.

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

    I can proof. You actually need to do not 5000, but 4001 (additions). Because if you do 4002 additions and get 2000 score as return, you could have also done 4001 for 2000 score with the strategy — do one addition — cash the score

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

    It don't know understand why you need to do that , main thing is that only 1 such position is possible after 0-array , so brute force till k , then all will give 1

    for(ll i = 0; i < k ; i++){
         ll cnt = 0;
         for(ll i = 0; i < n; i++){
           if(a[i] == (i+1)) cnt++;
         }
         ans = maxm(ans,cnt+((d-i-1)/2));
         for(ll j = 0 ; j < v[i] ; j++){
              a[j] += 1;
         }
      }
    
»
5 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

I tried to solve B using DP, but got Memory Limit Exceeded at test-case 3, anybody else tried it using recursive DP, or DP?

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

how to solve 'B'!!!

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

    you can observe something from enumrating the resulting substrings

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

    for every suffix[i] from n-1 to 0 :

    I erase second character until s[i] is the same as second char. (count += i - last occur of s[i])
    
    I dont use fisrt type operation because the string will be the same as suffix[i+1].
    
    so I just store the position of last occur s[i].

    my submission here

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

what happens if you submit right answer twice for pre tests?

i submitted D twice to avoid tle later.

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

Can anyone check why my code for C is wrong? I have been staring at it for 1+ hour and couldn't find the problem.

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

    In the last 'for' loop, you are checking for the valid indices only till b[j]+1. You need to check the whole array.

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

      Oh my bad, that was a last 15 seconds desperate attempt, I meant the one before that where I have b[j] instead of b[j]+1.

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

    i think when u added to the first b elements in the array, you checked if an element became "good" meaning that a[i] = i but not if an element is now no longer "good"

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

C is greedy af

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

I have skill issue.

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

The problem set is crazy :)

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

D always getting wrong answer on pretest 5, what a sad Christmas Eve :(
BTW, could anyone please tell me what's wrong with my code 238736754 ?

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

    Oh I see, forget to take those power of 2 exceeding ±20 into consideration ...

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

Not putting N = 2, K = 2 in the samples of E is cold-hearted lol :P

Also imagine debugging WA on E for 15 mins after "handling" this case just to make this fix and get AC ._.

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

Условие задач написано неправильно или непонятно

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

Couldn't solve $$$C$$$. How to learn to notice all, what needs to be noticed?

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

    You don't need to do so. Its just that after you do a reset operation then you can't get score greater than 1 after any number of operations. So its optimal to take a score of one from first element greedily after doing 1 reset operation

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

    How many can you get from first reset op?

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

    Here is my solution by the way, which didn't passed probably because of bug in implementation.

    Fix an element in array $$$a$$$. I want to know, when it is good, i.e. $$$a[i] = i$$$. If $$$a[i] < i$$$, then after some movements on array $$$v$$$ it will become good, then it will become bad forever. Sounds like scanline. Let's calculate for all elements of $$$a$$$ the segment of numbers of operations of type 1 after which the element is good. Process them in decreasing order. Fix $$$i$$$. Then all $$$v[j] \ge i$$$ change element $$$a[i]$$$. I want to know the position in cyclic array $$$v$$$, after which $$$a[i] = i$$$, i.e. I want to know $$$(i-a[i])$$$-th element of array $$$v$$$ with only elements which $$$v[j] \ge i$$$. Assume, they are in some structure. Let there are $$$x$$$ satisfying elements in array $$$v$$$. Then I need to traverse the whole array some number of times, and them some prefix. So I need to be able to find $$$k$$$-th element. I can do it with Cartesian Tree (Декартово Дерево), or with "indexed set" (google "cses.fi Josephus Problem II").

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

div1 difficulty

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

Can someone pls explain an approach for C?

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

    My English is not good,in my opinion,the sequence is like stairs,because it can be added to ans when it equals to it position,so every time you do opreation [1,b[i]] +1,it will break the stairs,so if 1-n is 0,only 1 or 0 can be added to your ans after several +1 opreation. To be the best,you can do opration 1 once and do opration 2 once.In this way you can add 1 to ans for two oprations. after understand it,you can make a brute force on array 'a' to Calculate the best ans. it will be allowed on O(n*n) , you can according to my ans 238725053. I Hope i can help you.

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

      Thank you much. I understood your solution) But there is one question. Why do you brute for i <= min(k, d-1). Why not further?

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

Thank you for spoiling the mood for the new year :(

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

Codeforces ------- NO
Speedforces ---- YES

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

    True A and B were speedforces couldn't say the same for rest of the problems

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

why we need to check 2*n instead of n in C?

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

    really? how do you know

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

    Yes because if it doesn't get give better result in this range there's no way it will give better if it's more since you can increase the score by 1 in 2 steps. I didn't realise that and checked way more than this by throwing and got Ac

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

    Here is a case where checking up to $$$n$$$ fails:

    1
    4 3 6
    2 0 1 2 
    1 4 1
    

    Only optimal solution is doing op 1 five times then op 2.

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

      After doing op1 5 times the array is [7 2 3 4] and doing op2 => answer is 1

      But that is not the optimal solution

      [2 0 1 2]

      op2 => answer = 0 [0 0 0 0]

      op1 => [1 1 1 1]

      op2 => answer = 1 [0 0 0 0]

      op1 => [1 1 1 1]

      op2 => answer = 2 [0 0 0 0]

      op1 => [1 1 1 1]

      Answer is 2

      Did I understood this right?

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

        Doing op2 on array [7 2 3 4] gives 3.

        Op2 counts the number of indices $$$i$$$ where $$$a_i = i$$$, in this case 2 3 4.

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

    more like max(n,k)

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

optimizing knacksap with bitset is uninteresting

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

I think div2 B should be easier or I'm not participate enough

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

Please explain why tourist's solution to problem C 238680690 passed the time limit. I think the condition in the for loop is doing the optimization, but I do not understand why.

for (int u = 0; u < d; u++) {
   if (n + (d - 1 - u) / 2 <= ans) {
     break;
   }
   ...
}
  • »
    »
    5 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    d can be upto 1e9 which goes way above the constraint

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

    If n + (d - 1 - u) / 2 <= ans then this and the future iterations are useless since they won't improve the answer. And since the initial ans is $$$\frac{d - 1}{2}$$$, any value of $$$u \ge 2n$$$ will be useless. Therefore, this cycle performs at most $$$2n + 1 = \mathcal O(n)$$$ iterations.

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

noting to say, but good night

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

nothing to say, avarage armenian round

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

min(n, k) gave wrong ans so i submited it with k i forget about k = 1e5 after wrong ans test 3 now waiting for fst :( now +60 will turn int0 -60

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

    You don't get FST because $$$k$$$ is large, you get FST because checking the first $$$k$$$ days is not enough.

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

      bro why is there no pretest regarding this. btw thanks for yesterday's contest problems were really interesting even though i didn't get them during contest but i enjoyed during upsolving them

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

E: You are given an even integer n and an integer k

I missed the "even", I would have been able to solve it if I noticed that. Now I think I have a working solution for the odd n. Could have been a nice E1 and E2 problem.

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

    Yes, I didn't think a lot about odd $$$n$$$, but yes it's solvable (check Bonus in the editorial for the problem E)

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

    Ohh What fresh hell is this !!

    Really feels bad when you misread the problem.

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

For C I have an Idea, You can just keep doing Op1 till you get the max score out of it. Than hit the reset button i.e. do op1 and op2. So finally (mx_score + (d — op1)/2)

And this came after the contest is over. :(

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

This contest was OVERKILL for me :(

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

Can anyone tell me whats wrong with my code for Question B? https://codeforces.com/contest/1917/submission/238702690

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

B was tough to understand that the second occurrence wouldn't affect the answer but will be counted.

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

Why did my solution to C pass? I don't understand why it works.

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

C became a scam

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

Can anyone tell me what's wrong with my code for task C? I have WA2 and O(n * log^2 k) asymptotics. 238736328

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

You guys were solving B with a set?

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

    simple observation of first and last test cases: in first — aaaaa all chr are same and ans is 5; in last -abcd.... all chr are unique and ans is 210;

    so we can assume that initial ans should be sum of 1,2,3..n, and we need to subtract some value when we have same characters: so first test case ans is 5 (15 — x) x is 10 here right, and for last is 210 — 0. and if you continue you could find this x calculating from similar chr in s

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

      But why my approach do not work for summing up the diff initial char and last occured char using map

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

    I did solve using a set. Code

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

      Yeah there's like a couple hundred (?) copy pasted solutions like this

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

      Could you explain why counting pairs?

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

        Consider the string abcdef.

        I just wrote a tree describing all the possible strings. Something like this:

        .               abcdef                        <- len 6 string
              bcdef               acdef               <- len 5 strings 
         cdef      bdef         cdef      adef        <- len 4 strings 
        def cef  def  bef    def  cef  def   aef      <- len 3 strings
        .......                                       <- .... so on... 
        

        At length 5, cdef is constant. if a and b are the same, then there is only 1 string possible. else 2 strings are possible.

        At length 4, def is constant. If c and b are the same, then there is only 1 string possible. else 2 strings are possible. If c and a are the same, then there is only 1 string possible. else 2 strings are possible.

        At length 3, ef is constant. If d and c are the same, then there is only 1 string possible. else 2 strings are possible. If d and b are the same, then there is only 1 string possible. else 2 strings are possible. If d and a are the same, then there is only 1 string possible. else 2 strings are possible.

        so on...

        Calculate for each length and sum them up in answer.

        PS: Fixing current character and comparing with previous seen characters is what I've considered as pairs.

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

          So we already saw ef then we need to add pairs,

          Then we saw def

          Then cdef

          and so on.

          So your soFar set is describing this phenomena

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

            Yes, for example: at length 4, i=2 current character is c and it's compared with previously seen characters b and a.

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

Congrats to guys who solved C! And I have a question, can we approach to this problem in this way, so everyday we compare two values: either we choose first option (cnt of all a[i] == i+1) or we go with second option to increase a's values (cnt of a[i]+1 == i+1 for i in range(0, v[day]) and compare this two values. And we implement it to every day. Is this correct approach?

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

Why so many solutions fsted on C?

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

    They simulate the process from $$$1$$$ to $$$k $$$

    However we should simulate from $$$1$$$ to $$$2n+1$$$

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

      Can you explain why $$$2n + 1$$$?

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

        If we do $$$x$$$ updates before getting the score $$$c$$$ in the $$$x+1$$$th step , the total score is $$$c$$$

        But if we perform the operations normally (for a 0-array) the contribution will be $$$ \lfloor\frac{x}{2}\rfloor$$$

        Than it is optimal to make updates in which $$$n\geq c\geq \lfloor\frac{x}{2}\rfloor$$$

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

      Is it because I would have gained $$$n$$$ points in $$$2n$$$ days if the array were reset to 0. The maximum I can gain from an array is $$$n$$$ points and doing it beyond $$$2n$$$ days is wasteful.

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

    min(2n,d) may be greater than k.

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

I love this round.

I love the super-weak pretest in C, which make me fst.

I love the interesting problems C and D, which made me stuck in implementation and debugging.

I love the random constructive problems taking the place of E and F, which makes the diffculty distribution so unbalanced and weird.

Oh. How I love it.

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

    F is not constructive and implementation of C is very short. About weak pretests, I'm sorry.

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

Thank you for the weak test cases for problem C.

Now I can reach Expert with the help of FSTs.

By the way, thank you for the awesome round!

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

I wasted 15 minutes because I put n instead of 2n as the limit of days to use second op in C, but least my n log²n D didn't TLE'd and I'll need to use magic to become purple again :)

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

my color changed twice in 2 contest :D

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

Not inserting a test into the pretests for one of the most possible error patterns in C is a bad Christmas gift.

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

c

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

A to C was fine. but D was too much

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

actually 2n days will give n points so if we waste 2n days then automatically we will get the max value i.e. n so if we are acquring n points after 2n days it is a waste its better that we just do the second operation then

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

worst round ever

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

Merry Christmas everyone!

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

Thanks for round! Tasks were really cool.

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

Beautiful problem F! Thanks!

»
5 месяцев назад, # |
Rev. 6   Проголосовать: нравится +8 Проголосовать: не нравится
I have a different solution for D than the intended one :p, and doesn't use the fact that p is a permutation

Here is my code : 238726631

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

In Problem C: Checking over the v sequence only once was enough to pass pretest. At least this major corner case should have been included in pretest which is in test no. 26 :(

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

Can anybody tell How Problem B can be solved using DP since in the problem itself the tag is mentioned of DP

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

test 26 of problem C is like the grinch :(

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

I liked Problem E very much, thanks _LeMur_! I upsolved it. My idea with 6 was following: if k is small, then print the diamond of 6 ones on the first 3 lines of matrix, then fill squares of 2x2 on the following lines. And symmetrically opposite: if k is large, then subtract k = n*n - k, and do the same with inverted bytes.

Somehow my Perl code is running notably fast. Submission — 238764454.

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

    Problem E-bonus (n can be odd):

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

C is really good but i didnt solve it during the match TwT

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

please anyone tell me the problem in my code for problemm D: submission link: https://codeforces.com/contest/1917/submission/238781581

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

Guys,my rating for recent educational round was taken back.Is there anyone who is having the same problem?

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