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

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

Привет! В 19.05.2023 17:35 (Московское время) начнётся Codeforces Round 874 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6-8 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Мы постарались сделать приличные тесты — так же как и вы, мы будем расстроены, если у многих будут падать решения после окончания контеста.

Вам будет предложено 6-8 задач и 2 часа 15 минут на их решение.

Штраф за неверную попытку в этом раунде будет равняться 10 минутам.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в пяти рейтинговых раундах (и решить в каждом из них хотя бы одну задачу)
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацией нашей работы. Задачи были придуманы и написаны командой Университета ИТМО: MikeMirzayanov, myav, Aris, Gornak40, ibraevdmitriy и Vladosiya.

Также большое спасибо: pavlekn, KoT_OsKaR, natalina, vladmart, Phantom_Performer, Be_dos, ctraxxd, diskoteka, lunchbox, kzyKT, MODDI, molney, FEDIKUS, Nickir, 74TrAkToR, kamishogun, KseniaShk, Sokol080808, NintsiChkhaidze, Asad5059, heon за тестирование раунда и весьма полезные замечания. Список тестеров будет пополняться.

Всем удачи!

UPD: Разбор

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

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

Hoping for the delta ++ ^..^

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

Hoping for positive delta

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

Finally, an unrated div3 for me!

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

Wishing a good div for one piece fans

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

wishing a good div for one piece fans

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

As a tester, i'm highly recommend to participate in this round. I think, one of the best div.3 round.

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

In my opinion every round goes good but when some unrated participants make fake id's and participate in the contest, the contest is ruined for programmers like us i hope we don't face any external problem in this contest .Good luck to all!!

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

Please provide hints and proofs for the problems along with editorials It helps in upsolving and understanding concepts for beginners instead of directly jumping to solutions :)

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

hope to be a wonderful round and end up with a big postive delta:)

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

if i do not register for contest and do not solve any single sum, can i still hack others solutions ? And will there be any rating decrease for unsuccessful hacks if i dont give the contest ?

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

Думаю будет отличный раунд! Всем удачи!

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

As a tester, I would highly recommend this round! The problems are very interesting with neat solutions! Statements are also pretty short!

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

who is MikeMirzayanov? CF community tell me about the living legend.

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

Hoping for a smooth contest and great problems.

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

As a tester, I would suggest participating in the contest :) Problems are cool and challenging.

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

Feeling this will be an hard round

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

As AI Bard, I will be participating in this round. Hey newbies, it would be a shame if you lose to Bard.

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

XD

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

Hoping for a balanced and interesting problemset :)

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

Hoping for no cheats :{

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

Hoping to score a chance to AK this competition!

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

nice contest

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

If you want to watch me spending 15 minutes on problem D, here is a screencast. (It is unable to be viewed until the end of the round.)

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

div4 or div3 contest?

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

Really good contest to return to Codeforces after a month of exams! Looks like it will also take me back to specialist :) I didn't have time to do F, was it some nCr + binary search?

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

    Not really (at least not my solution). The observation was that since the difference between any two levels is strictly less than m, then the selected dancers must form a permutation of [a, a+1, ..., a+m-1] for some a. I just did a sliding window with modular inverse on each contiguous range with length greater than or equal to m, using a map to keep track of occurrences.

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

      Hm, my initial idea was to sort the array and binary search the greatest possible value that could be included and then add how many ways you could choose m-2 numbers from the set of numbers between the first number and the greater number to the asnwer.

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

      Similar here. But I sorted the array, remove duplicates then do sliding window of size m.

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

        Same here. Except for I didn't have time to write modular inverse:(( Would've become expert. Here's my submission: 206546474

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

          i just made the logic quickly that i have to cnt the frequency and store in the vector of pair but i couldn't remember i have to change size also i was looping for n all the time after 40 minutes I realized then suddenly change the size and submitted at the last sec then realized didn't comment the extra printing variables and then contest is over and submitted after a sec of the contest and accepted :)

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

Am i the only one who struggled with recursion in E?

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

lmao gonna lose some rating because I didn't even check restrictions of D for quite a while

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

    Same, I really tried to force an O(n) with casework until I just gave up and bruteforced every array starting with the best possible number.

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

      How to do D?

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

        For permutations starting with the max number, you can generate all possible arrays starting with max-1 in n^2 time. For permutations not starting with the max, you can generate all possible arrays starting with the max in n^2 time. Then just sort all the arrays you generated.

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

    I didn't realized the restriction of D is small until I saw your comment lmao. Luckily it didn't take me too much to come up with a $$$O(n)$$$ solution.

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

Does anyone's code for F was failing on test case 4 ?

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

I couldn't implement it, but is this idea correct for E?

a = # of connected components, b = # of cycles

Get the number of connected components and if it is a cycle then b++.

so if a == b min and max value is same, otherwise min = b + 1, max = b + a.

Plz confirm this, thx.

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

Problem D was so MESSY for me, but maybe I'm just stupid

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

can someone tell me how to find min no. of dance round in E ??

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

    Connect each pair of dancers with a DSU and count the number of connected components. Notice that, for every connected component, if there exists at least one dancer that does not know both of its partners, it can be merged with another connected component.

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

Thank you for the great contest. Really liked problem E and F. Although, I got 2 mins late while submitting F. I guess F was easier than E. It was just a combination of binary search and segment tree.

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

STLforces

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

Waiting for editorials^_^

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

lol for D, N<=2000. I noticed it but somehow continued trying O(N) solution and I don't know why...

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

    D is doable in O(n).

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

      Exactly, but after getting the necessary observations to solve D, my brain automatically forgot about N<=2000 and tried doing O(n) since it was doable (and I was too lazy to impl it so I went to E instead).

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

      Can you share some insight on how to solve D in O(N) instead of O(N^2)?

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

        Suppose a[0] != n (otherwise we can do something similar with n-1). Let i denote the index of n in the permutation. We want n to appear at the beginning, so we need to choose a segment ending at i-1. We must include the suffix starting at index i.

        We need to include index i-1 in the segment, so the new permutation is [n, a[i+1], ..., a[n-1], a[i-1], a[i-2], ..., a[j], a[0], a[1], ..., a[j-1]], for some index j. (Obtained by reversing indices j through i-1). To determine whether to extend the segment to index i-2, compare a[i-2] to a[0]. If greater, it's better to include it because otherwise a[0] would necessarily come afterward, which is smaller. Otherwise we should stop the segment and append the prefix (since we care about lexicographical maximality). If we extended the segment, we compare again for index i-3, and so on until a[j] < a[0] at which point it is optimal to end the segment. This takes O(n) time and it's not hard to see that it produces the correct answer.

        Note that if n is the last element in the permutation, we can also reverse the whole permutation, so we should take that into account. Also, you are allowed in this case to move n in front of all other elements.

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

      It's possible but it's tricky due to the edge cases that arise from the fact that empty prefixes and suffixes are allowed, but the middle portion (that is reversed) must be nonempty. I'd definitely recommend the more brute-force O(N^2) solution instead: faster to code up and less chance of errors.

      Fortunately, the sample input contained a lot of the tricky cases already.

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

        I don't think my solution was really tricky.

        206488860

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

          That's a nice solution but I think it's still quite tricky with all the conditionals. Honestly I think that's more complicated than the O(N) solutions to problems E, F, and G.

          By the way, I'm not sure if you know that Python compares lists lexicographically by default, so instead of this:

              z = 0
              for i in range(n):
                  if a1[i] > a2[i]:
                      z = 1
                      break
                  elif a1[i] < a2[i]:
                      z = 2
                      break
              if z == 1:
                  print(*a1)
              else:
                  print(*a2)
          

          You could write this:

              print(*max(a1, a2))
          

          Except there seems to be a weird edge case for N=1, where you construct a1=[1,1] and a2=[1], so you need to handle that somehow.

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

        Yeah, I feel like it is solvable in O(N) but all the case work just make it not easy to organize, then I noticed the problem constraint allows O(N^2) solution.

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

someone please help me with problem D?

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

    First let's say maximum element={n if a[0]=n else n-1} Let indexMaxi=index of maximum element. fix r once as indexMaxi and once as indexMaxi-1. iterate over all l and choose the best answer. O(n^2) simple ,for O(n) you have to consider cases (I was getting frustated figuring out each edge case)... Solution

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

      why are we considering two indexMax? what's the intuition ?

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

        One case is that when the maximum element which is n is not on the index 0.In that case you can bring n to index 0.The other case is that when n is on the index 0.Then whatever operation you perform n can't remain on index 0.So then we will bring n-1.Instead of doing casework for the 2 cases separately,we check both and take the best answer.Hope it helps.

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

solved E after contest finishes. using simple dfs and some edges cases

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

D consumed lot of time for me:(

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

Vladosiya problems E and F were in the wrong order in my opinion because problem E is converted to a graph problem and requires graph knowledge which is harder than a brute force problem. (You have to convert it to graph and solve it) but F was very easy. In the last hour of the contest i read task E and got stuck on it, but in the last 10 minutes i read F and solved it in less than a minute but i wasn't able to code it in 10 mins and i upsovled it 10 mins after the contest ends:(

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

My solution for F was failing for test 3 and I cant understand why. I was using long long so I dont think it should be because of overflow. My idea was to maintain maintain the count of dancers with some value v , sort this and do a sliding windown to find m consecutive numbers. Maintain their product. Use modular inverse for division. Would have become ab expert had this not happened :< .

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

Can somebody explain how to take care of pairwise distinct in problem F?

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

I forgot to handle the special case of n=1 in Problem D, causing me to get it wrong 5 times.

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

div4

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

Actually, I couldn't understand the statement of problem E, even after about 3 and 4 times reading. However, I figured out the solution only by drawing the graph of all test cases and guess. A bit lucky for me.

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

Похоже в этот раз будет много отменённых решений после системного тестирования

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

Hello Everyone, In problem G, in am trying to use queue and traverse along minimum indegree to it's parent and find answer accordingly and update the queue, but somehow i am getting WA , here is link to my submission , any help will be appreciated.

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

Why many Java solutions of B are getting hacked? What's the tc?

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

For those who are interested in the solution for the problems of this round, feel free to check out my video of me solving and explaining them :)

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

Why O(n^3) solutions in D got accepted

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

    Because the maximum $$$n$$$, 2,000, is not very large. A naive solution for D, which constructs each possible flipped permutation and compares it to the maximum found so far, will use around $$$n^3/2$$$ operations to construct the permutations, but each operation is quite simple, just a 32-bit load and store, if you use ints to store the permutation. If the compiler can optimize by chunking these together into 128-bit loads and stores, this means you have to do just 1 billion of these operations in 1 second, which is possible.

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

I got stuck on problem G in test 3 (I passed 157 test cases on it), but I don't understand my mistake. I used BFS, and I know the other idea of DFS, but I want to understand what went wrong with my BFS implementation.

Here is the link to my code submission : https://codeforces.me/contest/1833/submission/206574785

Could anyone please help me?

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

Just come back after a year, better creating a new acc for the fresh start!

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

A very interesting contest. I've solved 2 problems for the first time!!. Lets go!!

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

Could someone help me solve problem of my code for C problem. I got TLE on test 11,which n is 2000000 but the another 2000000 is passed in less tham 100 ms. Thanks.

My idea is to anlysis whether this number can become odd or even num by a_i-a_j,so I sorted the array to reduce the time using.And if allow num can be odd or even output yes,either no.

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

Can someone help me solve the B problem? Sorting the b array directly using Arrays. sort() will timeout, but shuffling the b array and sorting will not timeout. AC code: https://codeforces.me/contest/1833/submission/206582027 TLE code: https://codeforces.me/contest/1833/submission/206582200

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

Problem F is fantastic

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

Can anyone share your approach for G?

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

When will the ranking points update (sorry i'm new here)

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

Tutorial?

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

why is it so, my answer was accepted yesterday and today they are in queue ??

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

Nice contest. Was able to solve till D. Can someone explain me problem E? I didn't understand the samples for minimum round of dances.

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

    If there is group A-B-C-D-A, it can't be minimized. But if you have E-F, G-H, I-J, you can connect them into one group. Each dancer may have 1 or 2 partners, no other variants, so you can count dancers with 2 partners and with 1 partner. Those with 1 partner may be minimized:

    # if there are dancers with only 1 partner
    if (dancers_1 > 0):
      min_groups = max_groups - (dancers_1 / 2 - 1)
    
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

please add the rank list in the blog :'(

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

There are WhatsApp groups available that offer solutions to contest problems while the contests are ongoing. Please get them blocked if possible.

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

Is it rated?

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

I just received an email tells that my solution is matched with another solution.

I have another account which has rate 1700 (Div3 is unrated to it), So when i solved the problems in this account, i just submit the solution from my other account (and its not rated to it).

Should System Skip my participation in this case? If not, Can you let this round be rated for me, I don't think that i made rules violation at all.

System

MikeMirzayanov

This is my other account Ismail_Alrifai

my submission from this account 206533710

my submission from other account 206536131

1833F - Ira and Flamenco

Codeforces Round 874 (Div. 3)

Thank you.

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

All the questions in this round were simple enough for plagiarism to occur, it's so stupid to impose plagiarism for A and B. My solutions have been found similar to someone, that's totally possible because of the simplicity of questions. I obviously did all those questions by myself and there is no sharing involved at all. I request to give me back my rating changes.

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

There's some problem with the system plagiarism checking system, hopefully codeforces recognise that the chances for the 4-5 line code, straightway questions, being same are like over 70 percent, it's so weird to impose plagiarism, remove that from my handle, I'm oviously honest.