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

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

Привет, Codeforces!

Я рад пригласить вас принять участие в Codeforces Round 951 (Div. 2), который состоится в 06.06.2024 17:35 (Московское время).

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

Вам будет предложено 6 задач и 2 часа на их решение! В раунде могут быть интерактивные задачи. Рекомендуем прочитать этот пост.

Все задачи были придуманы и подготовлены мной. Хочу выразить особенную благодарность Greg908 за обсуждение новых идей по задачам и незаменимую обратную связь.

Я хочу поблагодарить:

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

Разбалловка: $$$500 - 1000 - 1500 - 2000 - 2500 - 3000$$$;

Всем удачи!

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

Div. 2:

  1. Tanikaze_Amane

  2. olmrgcsi

  3. PMPuns

  4. Meguhine

  5. Sylphrena

Div. 1 + Div 2:

  1. turmax

  2. jiangly

  3. kotatsugame

  4. peti1234

  5. BurnedChicken

Разбор вышел!

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

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

Scoring is an AP! Been waiting for such a round.

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

Look who's doing purple testing

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

Hoping +ve Delta

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

    Forget about +ve delta dude. CF is brutal.

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

      agreed, solved C before B , B took almost 90 mins. again i am going down from so close from expert

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

        lmao, author so obsessed with cyclic shifts he applied one to the problem ordering of B,C,D

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

        how did you come up with the idea of B?

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

        Not as close as me :(

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

        Damn you applied binary search, thought but couldnt make it on time

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

        B is easy with the right observation approach. C was more tricky, and D kinda casework-heavy. Managed to solve up to D.

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

        can anyone help me by telling if this approach can work for b or not so lets say there is a common segment of length n between the sequences a and b.

        • let the starting element from a be :- a xor x
        • the starting element from b :- (a+k) xor y
        • here k can be any integer such that a>0 and a+k>0
        • now, sum of sequence from a :- (a xor x) + ((a+1) xor x) + ((a+2) xor x) + .. till n terms = (n*a + n*(n-1)/2) xor x (let it be sum1)
        • similarly from b = (n*(a+k) + n*(n-1)/2) xor y (let it be sum2)
        • now since both these sums are equal (sum1 = sum2) therefore, (sum1) xor (sum2) = 0

        • sum1 xor sum2 = ((n*a + n*(n-1)/2) xor (n*(a+k) + n*(n-1)/2)) xor (x xor y) = 0
        • therefore ((n*a + n*(n-1)/2) xor (n*(a+k) + n*(n-1/2)) = (x xor y)
        • after solving i found out :- a = (c xor (n*c + n*(n-1)/2 + (n*c) xor d) / n (here c = x xor y)
        • if for some 'n', 'a' comes out to be a natural number and a+k is also > 0 then we can binary search over all values of n.

        if anyone can help me , can this work

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

          I have no idea why you make it so complicated. B was literally this easy, I solved it in 5 minutes:

          ll ans=(X^Y)&-(X^Y);
          
          • »
            »
            »
            »
            »
            »
            22 месяца назад, скрыть # ^ |
            Rev. 2  
            Проголосовать: нравится 0 Проголосовать: не нравится

            man, i am absolutely terrible at bit manipulation. even though i am noob at cp, but at bitmasks and all my mind just gets stuck. how do you even come to this 2^k conclusion. any tips ?

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

              Okay, so here's my thought process: If two XORs are equal, that means XORing both sides produces 0. Therefore, you can introduce a new variable, $$$Z=X \oplus Y$$$. So XORing something with $$$Z$$$ produces 0 when the other mask has the same bits. Therefore $$$a_{i} \oplus b_{i}$$$ must be $$$Z$$$. It is achievable when they differ in bits where $$$Z$$$ has 1, and have the same bits where $$$Z$$$ has 0. That means, if we know $$$a_i$$$, we know exactly what $$$b_i$$$ should be. So the last 0s in $$$Z$$$ means that there is a match between $$$a_i$$$ bits and $$$b_i$$$ bits. Increasing $$$a_i$$$ will result in an increasing $$$b_i$$$ as well. But when the bit flips at the first position where $$$Z$$$ has 1 in $$$a_i$$$, $$$b_i$$$ should flip too, which spoils the increasing pattern. Therefore, check the least significant bit of $$$Z$$$. It is well known, that x&(-x) returns the LSB of $$$x$$$.

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

              it was an observation problem. I read the problem and got a rough idea that solution might contain something like checking which bits are matching and not, and doing something from there on. Then read the test cases.

              The test cases were a huge giveaway for this question. The output of 8 (1000) for 4 (100) and 12 (1100) (first 3 bits match from LSB and ans is 2^3) hinted that we might need to check for first few matching bits in binary representation. So just pulled up a calculator, and converted all test cases input to binary, matched with output, saw the pattern. That's it.

              Pattern: 1000...(as many zeroes as no. of matching bits in both nos. from LSB)...000

              Now the idea was not directly ll ans=(X^Y)&-(X^Y), but it can easily be simplified to that. You do need to worry about that. You could have just converted both numbers to binary and checked bit by bit manually for matching bits from LSB, and got the right answer. The notation is just an easier and mathematical way to do the same thing, which just comes over time.

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

                damn. so as soon as i see a bit manipulation problem i should just straight away start thinking and writing in binary representation.

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

                  bit manipulation by definition means bit — which in most cases refers to digits in binary form of numbers. Although I am only a specialist so you should take my words with some salt, but in general, bit manipulation problems are (almost?) always solved by using binary representation.

                  The tough part is not decide whether we have to use binary form for the bit manipulation, it is to identify whether the problem is of bit manipulation or not. To identify that, sometimes author of problem puts hints in problem statement, or constraints (like m<30, bcz 2^30 is 10^9, etc.), or in the sample cases (like this question, where analyzing cases gave away the entire trick). Sometimes there are no hints at all and we have to analyze the problem ourselves and come to a conclusion, other times a problem may look like "obviously" a bit manipulation problem but turn out to be something else.

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

                  okk. thanks for the advice. i will start practicing on some bit manipulation problems keeping in mind these things. btw what basic things would you advice me to learn for bit-manipulation like how to find OR of range of numbers and all.

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

                  I learnt all this quite some time ago so I don't remember where exactly I learnt it from, but there are plenty of resources on google, maybe some resources on codeforces catalogue section also might be there.

                  Another and probably the most important thing you should do is once you have solved a question, see others' solution. That way you can see different techniques which might be useful at other places. For example, in this question, you can explore why (X^Y)&-(X^Y) gives the same answer as the pattern matching I stated above (giving the position of lowest set bit), and in the process you may learn many new things. Just try to always explore and learn. Read editorials and everything.

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

      What is +ve delta,dude?

      • »
        »
        »
        »
        22 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится +10 Проголосовать: не нравится
        The uppercase letter Δ is used to denote: Change of any changeable quantity, in mathematics and the sciences (in particular, the difference operator[5][6]) — Wikipedia

        On Observation you may notice that the only changeable quantity after CF rounds ( or the most obvious one :P) is the rating of participants.

        " A positive delta " hence denotes a positive change in the changeable quantity.

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

I'm Salah Eldeen Al-Ayoubi

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

I'm wondering if any time when authors had indicated that interactive task "may" occur eventually it didn't appear. Since there is an exact number of tasks aka 6, I understand the author knows exactly what tasks are the final ones, unlike when you are not sure which tasks will be final and provide a spread (like 5-7 tasks) where indeed interactive tasks may but may not occur. Is there any reason to be not explicit in such cases? ;)

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

wishing to get +4 and not brick like I did last time when I needed +3 for cyan :)

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

hope to reach specialist this round <3

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

Hope to return blue color for my handle ;)))

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

Is this round mathforces or algoforces?

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

Good luck to everyone except no one!

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

Interactive tasks may occur in this round

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

I always get stuck on C in a div 2 contest.

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

Waiting for starship launch as well as div2

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится
Score distribution
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good Luck Have Fun!!

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

Best wishes for everyone's A, B, C and D.

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

рофлотурик какой то

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

I want to thank to the cosmic entity which come from heaven that come up with Problem B was great problem. I mean who in the right mind thought , ya problem B looks super cool and amazing , people will observe the test case even if it takes 80 minutes , btw solved C in 20 minutes

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

mathforces

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

Samplecase forces ,or maybe I need a lot more practice

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

My solution to C without LCM 264475190

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

Guessforces

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

Hint for C anyone? ;)

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

I gave up on E, so here is your partial editorial

A:

Hint 1: What is the way to get the smallest maximum of a range of more than one element.

Hint 2: Look at only pairs of adjacent elements

Sol:

Search every pair of elements. Answer is minimum of the maximum of pairs — 1.

Code:

https://mirror.codeforces.com/contest/1979/submission/264409254

B:

Hint 1: Think about BITwise.

Hint 2: Look only at the first few elements in the list until items differ.

Sol:

Find the difference between a and b. Answer is the maximum power of 2 that divides this difference.

Code:

https://mirror.codeforces.com/contest/1979/submission/264415773

C:

Hint 1: Think of a way to equalize earnings.

Hint 2: What is the smallest number that is a multiple of all numbers.

Hint 3: How do we check if there is no solution.

Sol:

  1. Take the LCM of all multipliers.
  2. Put LCM/multiplier for each multiplier to guarantee earning LCM coins.
  3. Check if the amount of coins spent exceeds or ties LCM and return -1 if so.
  4. Else, print LCM/multiplier

Code: https://mirror.codeforces.com/contest/1979/submission/264427427

D:

Hint 1: How much change can one operation do to the string.

Hint 2: look at lengths of consecutive elements.

Hint 3: Is there any equivalent operation in the context of k-complete strings.

Debugging Hint 1: Pay attention to the last consecutive elements.

Sol: 1.Check each length of consecutive elements. 2.If all lengths are k, then output n. 3.If more than one length is not length k or last is greater than k, output -1. 4.Else, if broken length is less than k, set operation length to first c characters where c is the current charcter you are in the string. 5. If broken length is more than k, do the same but for the c — kth character. 6. Do the operation with the designated length or the easier to implement equivalent operation of reversing the remaining characters. 7. Check is string is k-complete. Code: https://mirror.codeforces.com/contest/1979/submission/264452915

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

holy cow i lost 55 min to find out i wrote var=- instead of var-=, how the hell i'm working in this sector?

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

it's really hard for us , honest pupils and newbiews to overcome cheaters

solution problem C was leaked . i didn't solve problem C though.

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

I predicted solution for B, C using case 4 in test 1

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

Should have solved C first instead of wasting whole time on D

Anyway, can anyone say how to solve D? I tried a lot. My idea was to divide the string into chunks of k size, and handle how many chunks are not of k size, excluding first and last chunk (handled separately).

Here is my submission, if anyone could debug it would be helpful : https://mirror.codeforces.com/contest/1979/submission/264475276

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

Did more than 13k+ people get B from observation only or was it the case that it's proof was trivial and simple?

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

    I think this was a really nice problem.

    Ai = i xor x

    Bj = j xor y

    If Ai == Bj=> (i xor x) == (j xor y)

    => i xor x xor y == j

    We can replace x xor y = k

    So we want

    i xor k == j

    (i + 1) xor k == (j + 1) and so on.

    And now one nice thing is that if i xor k == j

    And (i + x) xor k == (j + x)

    Then (i xor (i + x)) & k == 0

    The above statement basically means that all the bits changed from i to i+x are unset in k.

    Using this we can find the answer.

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

    I think the line of reasoning can be like this:

    1. Look at examples, and see that all answers are powers of 2. Googling "log2(33554432)" gives an integer.
    2. Looking at the notes on the bottom (or by writing a test script), notice that xoring all integers will not cause any duplicates or missing numbers, but numbers are instead shuffled and gradually increase. Choosing $$$x=1$$$ causes adjacent elements to be swapped. If $$$x$$$ is even and $$$y$$$ is odd, then they cannot have more than 1 consecutive equal element. Testing powers of 2, choosing x=8 will swap adjacent blocks of size $$$8$$$, giving $$$[8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,...]$$$. If y does not have the same bit set to 1, then any equal subarray between the two can have at most size 8.
    3. This leads to the strategy: pick the smallest bit $$$i$$$ that differs between $$$x$$$ and $$$y$$$, and take $$$2^i$$$. Trying this for the examples, it yields the same results.
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Random approach for C, I don't know if it is legal or not: 264455549.

Hack welcome.

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

Went on solving a completely different problem due to the typo in D

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

Just completed my code for E rip

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

    how did u solve E.

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

      Let's say we have a pair of points x,y and a,b at d manhattan distance, you can notice that the intersection of the pair of points will always be at x+-d/2,y+-d/2. Basically this means that out of the 3 points, atleast 1 pair of points must have a difference of +d/2 or -d/2 for both x and y coordinate. So, for each point out of n points you can just check if one of the 4 points exist or not, if they do, you can find the 3rd point using a set.

      For 3rd point, make two types of set, one set will be indexed by x+y and one by x-y, now you can just binary search for the third point.

      I still haven't accepted my code, so i might be making a mistake

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

I didn't feel that Problem C was easy. How come so many people have solved it? Was there something simple in the problem that I missed?

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

Nice problems

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

Maybe that's skill issue on my side, but problem E is the worst problem I've seen in a year. It's just annoying copy-paste of several cases resulting in 200+ LOC.

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

    Yeah, saw that and gave up on implementing it.

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

    You can try to rotate the grid 4 times and each time looking for one direction only.

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

    My implementation was also terrible. However, it is my own fault. My casework started with two cases and didn't look that bad. Then two turned into four, and four turned into eight. At this point, I was too invested to turn back.

    Looking back, there were multiple ways to eliminate a big chunk of the casework. You can take this opportunity to learn useful techniques and avoid extensive casework in the future. Or you can shift the blame to the setters and fall for the same mistake next time. The choice is yours.

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

Thanks for a good round! Pleased to come back for such a contest.

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

k is divisor of n cost me 4 WA and > 90 min

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

High rating guys are saying like questions getting relatively tough in nowadays contests,then how come large no of people are able to solve problems upto C,like around 9000 submission on C is insane.It's really getting demotivating.

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

What was the intution for D? My solution was O(N2) ;P

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

    Just use hashing for checking if the string after doing a given operation is equal to 000111000111... or 111000111000111... You have to do like rolling hashing or something like that in order to get the hash of the transformed string at each step

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

    Just brute-froced with hashes, I hope they won't FST :p

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

    You notice final string should be K size blocks like 111000111(for k = 3). Then you notice transformation is taking prefix, reversing it and addind to the end of the string. Then it is kinda obvious prefix must end on the first symbol where something gets wrong(because else this "wrong" part will get between good blocks and we can't do anything about it). Also if you see a block with size greater than k you should leave k last symbols of it and take the rest.

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

    Trick is to release that only one possible location can be flipped to create a k-complete string.

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

    find the first group whose size is $$$!= \ k$$$
    if group $$$size$$$ is $$$ \lt \ k$$$ consider the group in operation
    if group $$$size$$$ is $$$ \lt \ k$$$ consider first $$$k \ - \ size$$$ elements of group in operation
    then check if the resulting string is good

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится
    Somewhat of an explanation
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E?

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

Lucky again this round! \(^o^)/

B and C is pure guessing game for me and I guessed it!

And D is also kind of easy, maybe waste some time on debugging :)

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

    No————

    I should have solved E if even luckier, now I submitted my code and got AC after contest QAQ

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

    Could you explain how to solve D? Thanks! I feel like I definitely overcomplicated my thinking.

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

      The valid k good string must have k 1, then k 0, then k 1... or k 0, then k 1, then k 0... For example, if k=3, then its something like 111000111000... or 000111000...

      If the string is already k good, then you can output n directly. Otherwise, you just need to check the first place it gets invalid(when continuous characters's cnt != k), try to do the operation and check: after the operation, whether the string become a valid k good string or not. If it become valid, then you find the answer, otherwise you can absolutely not find the answer and you can output -1.

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

MathForces!!

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

Codeforces should bring "report cheating" option..so many submissions on B and C.

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

guessforces, no prove but ac

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

Am I the only one missread the statement of problem F?

Kostyanych tells you the number of vertex $$$v$$$ with a degree at least $$$d$$$

It takes me a long time, to realize that the number of, means the index of $$$v$$$, not how many vertexs $$$v$$$ satisfie the condition...

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

Fingers crossed for a positive delta ... Guessing theorems is kinda interesting :)

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

Problem B was tougher than C, at least for me, back to pupil.

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

Question C, I implemented it using binary search, but can someone explain the monotonicity issue?

https://mirror.codeforces.com/contest/1979/submission/264454069

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

I think tests for D are weak, because +-40000-optimization has passed: 264461313

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

quite curious, did none of the testers notice the typo in problem D?

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

I solved C without lcm. Lets S = 1e9 be the sum of all numbers. Then $$$x_i \cdot k_i \gt S$$$ for all $$$i$$$. Lets assign $$$\lfloor {x_i = (S + k_i)/k_i} \rfloor $$$ for $$$i \neq n. x_n = S - (x_1+x_2 ... +x_{n-1})$$$. if $$$x_n \cdot k_n \gt S$$$ we found solution.

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

Thanks for a great contest, maybe I am biased but more math related problems helped me solve 3 (when I usually solve 1 or 2). D looked like fun too. Too bad I can't write basic code, xD.

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

Finally I got out of 1700

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

I am a little curious and would love to see the stats of blue,cyan,green,and gray users who submitted b,c

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

Thanks for great problems, found D very interesting by solving with hashes

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

Finally becoming expert Thanks for such a great round

:D

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

Thanks iNNNo for the contest! Problems were quite good! I hope everyone was good today!

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

$$$B$$$ $$$C$$$ I have no proof I guessed solution , $$$A$$$ semi-proof , only in $$$D$$$ I had solution with proof but not quick enough to submit in time , AC after contest , such a bad contest for me

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

Does anybody know why my submission to B (264416480) shows "Pretests passed" still? Or is it only on my side?

Edit: seems to be fixed now!

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

I felt so happy solving C after a long time, only to see later that it had 9k solves :')

Thanks for the contest nevertheless, it was amazing iNNNo and all testers.

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

System test is far too weak ....

Even this $$$\mathcal{O}(n^2)$$$ memory and $$$\mathcal{O}(n^3)$$$ time complexity solution can pass the system test, and still I hack it:

https://mirror.codeforces.com/contest/1979/submission/264463080

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

    bro wtf, I can up with a O(n) mememory and O(n^1.5) time complexity solution, and thought that would fail.

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

      You sure that is $$$\mathcal{O}(n^{1.5})$$$ ? If you connect each pair with an edge, the number of edges can be $$$\mathcal{O}(n^2)$$$ if you see my case, which leads to a $$$\mathcal{O}(n^3)$$$ time complexity to find a circle of $$$3$$$ .

      I'm not sure what you are thinking about, but if what you do is something different, please tell me.

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

        No, I am talking abt a solution I came up with, in hindsight it is more like n^5/3

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

          That's kind of impressive, but it may still seem hard to pass. I'm really interested in the solution now lol.

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

            Trick is there are two solutions. Both hash all points such that it is possible to look up a point in O(1) time.

            If d is small. For each item look around the permiter of all points of distance d, maintain two pointers that are d apart from each other, and see if there is a place where both pointers land on two points. This is a O(nd) solution

            If d is big. Put each point into a box based of (x+y)%d. Brute force ech pair of points, and find third point in O(1). This works in O([40000^2/d]^2). I think.

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

$$$O(n^2)$$$ solution for problem D passed system test

https://mirror.codeforces.com/contest/1979/submission/264433381

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

For those who used string hashing brute force in D, how did you compute the hash for a given $$$p$$$ quickly?

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

    Just precompute the hash and reverse for the original string.

    build two possible answer string hashes.

    let's say for input:

    8 4

    two possible answer strings are 11110000 or 00001111

    get hash value of both of these strings.

    Then finally for each p,

    1) get the reverse hash of the string consisting of $$$s_1$$$$$$s_2$$$$$$...$$$$$$s_p$$$

    2) get the forward hash of the string consisting of $$$s_{p+1}$$$$$$s_{p+2}$$$$$$...$$$$$$s_n$$$

    3) merge the two hashes you got from step 1 and step 2 to get the desired hash value of the string if you had choosen this specific p.

    4) Finally, check if the hash you got in step 3 matches with any of the two answer hashes.

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

The problems are interesting, but maybe the system tests are not strong enough

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

I really messed myself up misreading D lol

I blanked out on the first condition and thought something like 101101001011 would be 4-proper..

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

Sorry, but I am unable to find the editorial has it been released yet?

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

Finally able to WOW at CM! Like the problems!

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

would anyone mind telling me why this linear submission for D resulted in TLE on test 2?

https://mirror.codeforces.com/contest/1979/submission/264488685

thanks!

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

D was an absolutely boring problem without any idea underneath

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

Is it really correct to use binary search for problem C? Why do I feel like there's no monotonicity?

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

Tests on problem D are kinda sad. Many brute-force $$$\mathcal{O}(n^2)$$$ solutions passed because they typically come with very light operations such as erasing the first element from a string or comparing two strings. From what I see in the original tests the strongest test that counters this is $$$k=100$$$, but with this test the 'comparison' ends too early so these solutions normally took ~1.5s only.

With $$$k=1$$$ and an almost-$$$k$$$-proper string, dozens of such solutions fail. There are some variations needed for some solutions that has additional checks, or have opposite direction check etc, but the basic pattern is the same.

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

I am unsure how this contest became rated. In Problem B, the original problem statement referred to a subsequence, not a subsegment. Instead of updating the judge's validation code and rejudging the solutions, the problem statement was altered during the contest without any announcements !!!

Artyom123

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

I really like the sample testcase for the D problem It actually help me a lot for AC

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

okay so i participated in this contest, and i copied answer from my one account https://mirror.codeforces.com/profile/aadarshsingh12345 to my another account https://mirror.codeforces.com/profile/zaprodiaq .I have ID/password of both, you can verify whichever way you want.. can i get my rating back ?

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

Can anyone tell me why I have used "fflush(stdout)" but it still shows "Idleness limit exceeded"? My Submission