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

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

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

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

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

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

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

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

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

Задачи были придуманы и написаны pashka, MikeMirzayanov и мной.

Часть задач раунда была в Cyprus Programming Challenge, если вы участвовали в нём, пожалуйста воздержитесь от участия в этом раунде.

Также большое спасибо:

  1. peltorator, FairyWinx за красное тестирование раунда.
  2. Vladithur, Valters07 за жёлтое тестирование раунда.
  3. stefanbalaz2, FBI, SlavicG, flamestorm, JuicyGrape, mesanu, trainerherp, Ush1su за фиолетовое тестирование раунда.
  4. dan_dolmatov, Yousef.Osama за синее тестирование раунда.
  5. Sergey140146659, Pa_sha, gas за бирюзовое тестирование раунда.

Всем удачи!

UPD: Разбор

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

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

hoping to return back the blue handle

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

I hope to be the statements short.. i think this better

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

Tomorrow is my birthday, and I hope to perform well in the contest. Wishing success for everyone.

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

First time testing :D Good luck to all!!

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

It's been a while since the last contest written by pashka, glad to see him.

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

Inshaallah, In this round I will be Green.

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

My first unofficial Div.3 contest! Hope it will be fun and good luck to everyone!

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

I hope statements are short and legible :D

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

I don't know why I'm not included, but it's my first time testing :D

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

As a tester, I enjoyed the problems, and I hope that you will enjoy them too

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

As a person, who participated in the Cyprus Programming Challenge, I can say that problems were fascinating. Good luck to everyone!

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

As a tester, I can say that problems are very interesting

»
2 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
  • Wow Bashka, Mike Mirzayanov contributed to the problems... I'm so excited
»
2 года назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

I might end up in top 100 in this contest.

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

I was wondering, why is that on some rounds (mostly educationals) the number of the problems isn't announced? Surely, authors know the number at least a day before the contest begins, and it's pretty inconvinient for the participants to not know that number (myself and I'm sure many others like to make files for the problems before the contest)

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

Will the round be delayed if this queue continue ?

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

Why is the round delayed by 10 mins?

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

Hope to become expert.

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

Again! one refresh cost me ten minutes

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

if you open author list of this contest using dark reader, you end up with a color scheme of russian flag

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

What are you doing during the few minutes of the contest delay,it is so suffering

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

what does it mean — to be an any color tester?

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

Nice

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

why do i get HTTP Status 403 — Forbidden error after refreshing the page during a contest ? How do i get rid of it ?

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

hardest div3c I've ever seen.

regular greedy approach simply not hold.

I'm losing hope in cp

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

cool problem G!

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

    How to solve it ?

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

      Let's construct the graph corresponding to. If we have a vertex of degree exactly $$$1$$$, then we either exactly take the edge coming from it, or exactly do not take this edge. We can do this one by one. Then we can prove that the remaining graph is a union of non-intersecting simple cycles. The solution for each of them is approximately the same. Let the cycle $$$v_1 v_2 ... v_k$$$. We have two cases: whether we take the edge $$$v_1 v_2$$$ or not. Each of the two cases is solved in the same way as the first part (if we take it, for example, then all other operations that are necessary are recovered uniquely).

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

hardest div3c I've ever seen.

regular greedy approach simply not hold.

I'm losing hope in cp

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

My thought process of G: build graph i-ai. pressing a switch is flipping endpoints of an edge. each op is xor which is associative so order doesn't matter and no switch will be flipped twice so op is delete an edge and flip its endpoints.start with leafs. corresponding edges are fixed. we are left with a bunch of loops. now what ?? even no of 1s should be present in a loop. 2 possible ways of pairing find the min one.

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

Why does my solution for problem D not work? Any help is appreciated.

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

How to do problem E?

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

How to do problem e?

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

Anyone Can give more precise view of E I just saw the first observation of how last character making answer and then rest what I did is in hurry and that worked LOL

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

Is G something like topo sort? My idea was to use topo sort until the remaining switches are in cycles, then see if every cycle has an even number of on switches. If so, then we are good.

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

C ruined the experience

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

    235953756 Can't find the bug for code in C :(

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

      what's idea of this solution

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

        The idea is basically from finding 2-majority element of a array without hashing,

        I am basically first storing the count of each charater occurance in hash array.

        After that, we lets define a process to reach minimum length which will be :-

        (We will take the current majority character x in string and we will remove any pair x adjacent to non-x in string.)

        if there is 2-majority element in array(if a element occured >= n/2 times), It will remain 2-majority after any no. of processes.

        else if there is not any 2- mojority element in array. After some no. or processes, if string length is odd than a element can reach maximum count of n + 1/2 elements and will remain 2-majority after that. if string length is even than a element can reach maximum count of n + 1/2 elements and will remain 2-majority after that.

        So, execute the process we defined on string and you will reach the answer after some analysis.(the solution I mentioned may seem tough to understand but it is simple when you will understand)

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

      I think it's because of vector of char instead of vector of int

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

      The above comment is true — it's because of the vector.

      Char is in range of [-128, 127] I believe, and the string can be up to 2e5, so if any character appears more than 127 times, char will overflow.

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

Hints for problem E? Thanks.

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

Solved F 20 minutes after the contest ended.

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

At first I thought G is 2-SAT. LOL

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

I cannot believe that I couldn't solve $$$C$$$ , I mean have I gotten really that dumb!!

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

I couldn't solve $$$C$$$ , have I really gotten that dumb!!!

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

    Relax, I've solved the EFGA problems :)

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

    don't worry, I took at least 15min to mind-solve it and even then it was just trying random approaches until I found one that worked (then I proved it, of course). And I'm a master...

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

      Hey, Can you just prove your solution for C

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

        First assume that n is even. Then I claim that the answer is 0 if no character occurs more than n/2 times, and maxcnt-(n-maxcnt) = 2 * maxcnt — n otherwise where maxcnt is maximum number of occurrences of any character.

        In the second case, we can see that the last remaining character is necessarily the one that occurs the most times, since it's impossible to remove all of them. (you can remove at most one per operation, and at most n/2 operations are performed so there's no way to remove all of them. The number of operations performed is bounded by the number of characters not equal to this most common character, which is n-maxcnt implying that at most 2*n-2*maxcnt characters can be removed. So the length is at least n-(2*n-2*maxcnt)=2*maxcnt — n. I claim that this can be achieved. Method: always try to remove exactly one non-most-common character per operation. This can always be done by choosing an occurrence of the most common character and one non-most-common character — it will always exist until all characters are made equal, at which point the length is 2*maxcnt-n.

        We can show the first case by induction.

        • Base case: n=2 then s1!=s2, then we can make the length 0.
        • Inductive step: suppose it's true for n-2, now prove for n: we claim it is possible to remove characters so that no character occurs more than (n-2)/2 times in the remaining string. Take the most common character and remove it with any other character. In this way we can see that the condition is satisfied with the remaining string and we can continue until the string is empty.

        When n is odd, the reasoning is similar, but since the parity of the length is constant, replace "0" by "1" in the above.

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

        You can always remove a pair which contains the most frequent letter, as long as all the letters are not the same...

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

It's my first time to complete 4. Can I turn green?

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

F implementation was tricky

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

it would have been interesting if e would have been not for triplets but n-plets (basically for n numbers rather than 3 numbers).

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

did any one else solve problem F using Hashing ?

my solution

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

Can someone please explain problem D, how BS is working there?

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

    [x,y] means interval from (inclusive) x to (inclusive) y.

    We have to jump into these intervals: [0,0] -> [1,5] -> [3,4] -> [5,6] -> [8,10] -> [0,1]

    We can check if this works if we fix k=3:

    [0,0] -> [-3,3] //we can jump anywhere here

    [-3,3] & [1,5] = [1,3] //this is the overlap. We can be anywhere here

    [1,3] -> [-2,6] //we can jump anywhere here

    [-2,6] & [3,4] = [3,4] //we can be anywhere here

    [3,4] -> [0,7] //we can jump anywhere here

    [-0,7] & [8,10] = [ERROR] //we have no overlap and nowhere to jump. K=3 does not work!

    Code:

    bool good(int k, vector<pii> &segs){
        pair<int, int> current = make_pair(0,0);
        for (int i = 0; i < segs.size(); i++){
            current = make_pair(current.first-k, current.second+k); //we can jump anywhere here
            if(segs[i].first > current.second) return false; //no overlap
            if(segs[i].second < current.first) return false; //no overlap
            current = make_pair(max(current.first, segs[i].first), min(current.second, segs[i].second)); //we can be anywhere here
        }
        
        return true;
    }
    
»
2 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Either brain's not braining or found the problem D much harder that usual don't know why...

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

How to solve G?

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

    Construct the graph $$$i \rightarrow A[i]$$$, this type of graph is well known (Functional Graph). An important property is that it consist of several cycles and nodes that following the directed edges reach some cycle. So obviously if there is a 1 on a leaf you have to change it and switch the next node. In the end you will only have cycles left, some nodes will have 0 others 1. If the number of 1's in a cycle is odd, then it's impossible. Otherwise let $$$A_1, A_2, \ldots , A_{2k}$$$ the nodes that have 1, then you have two ways to convert them to 0. Grouping $$$(A_1, A_2), (A_3, A_4), \ldots , (A_{2k-1}, A_{2k})$$$ or $$$(A_2, A_3), (A_4, A_5), \ldots, (A_{2k}, A_1)$$$. Choose the one that minimize the changes.

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

    Another way of doing it is by considering an undirected graph with edges $$$i \leftrightarrow a_{i}$$$. Now solve for each connected component individually. Notice that each connected component is a tree with one extra edge because there are $$$m$$$ nodes and $$$m$$$ edges, where $$$m$$$ is the size of the component. Try both using the extra edge or ignoring it. Now the problem becomes turning off all the lights in the tree, which we can just do using dfs.

    Submission

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

C>D>B>E>A

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

anyone finding Div3.D harder than usual ?

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

I think that the solution of problem B has been widely shared by cheaters. Here are some examples :

235939705 235936558 235937575 235905766

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

Nice contest! Problems very really good. Thanks a lot for the round Vladosiya pashka MikeMirzayanov and all testers.

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

This is a genuine plea for help, I have no idea how to approach problems like 1907C - Removal of Unattractive Pairs. The first thing my mind tries is a greedy approach, doesn't help, maybe check for DP, still no use. How do you develop the intuition to solve these type of problems, or even more fundamentally, how do we even approach these types of problems, when nothing else matters except a few observations that perhaps never strike you during the contest?

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

    I just saw that if we want to remove the letter with the highest count then pairing it with 2nd highest letter will be beneficial.... that's why I use set to maintain the order of letters on the basis of their count ... I pick the last and second last and delete them and the update them and reinsert it and this will cost log(n) and do this till the size of the set is greater then 1. we will do this for n/2 element so, TC will be nlogn. 235912384 there is math solution also but I come up with this one during contest

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

      Your solution always gives the correct answer, but the reasoning is incorrect: it's not always possible to remove two characters with largest and second largest frequency (remember that you need to remove two adjacent characters):

      $$$\mathrm{acbdaeb}$$$

      • $$$\mathrm{cnt_a} = 2$$$
      • $$$\mathrm{cnt_b} = 2$$$
      • $$$\mathrm{cnt_c} = 1$$$
      • $$$\mathrm{cnt_d} = 1$$$
      • $$$\mathrm{cnt_e} = 1$$$

      The most frequent characters are $$$\mathrm{a}$$$ and $$$\mathrm{b}$$$, but you can't remove both with one operation. This turns out to not matter: it's enough to remove the most frequent character with any other character unless the frequency of the second largest character is $$$\left\lfloor\mathrm{len}/2\right\rfloor$$$, in which case we definitely can remove the most frequent and second most frequent characters at once.

      upd: there are actually some other cases I missed but the main idea is still there.

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

      As adjacency of elements doesn't matter, to remove the element with the maximum count, we need the same amount of other elements, so the answer is the difference between the count of the maximum occurring character and the count of other elements. If the difference is less than or equal to 0, then we give the output as 0 in the case of an even-length string or 1 in the case of an odd-length string; otherwise, the answer is the mentioned difference.

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

    I have noticed that you can transform the string in a compression of it, example: "aaabbc" is converted to 3 2 1,then the new problem is given an array you can rest 1 to an adjacent pair of numbers any number of times and if a number become 0 remove it and refill the space and this new problem look easier for me to solve.

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

      I thought of this too but then consider the test case: vvcvvv. You will compress this to 2,1,3. However, the 2 and 3 cannot reduce each other since they are both instances of v. This is where I faced issue with my greedy approach. I do not know how to account for the fact that after some operations, 2 numbers in the array will become adjacent but they carry the same letter so they cannot reduce each other.

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

        of course the first observation to do is if a character appear more n/2 then you can delete all the others chars with an instace of it an the remaining ones will be the answer

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

        You just have to count the letters. Like a frequency list of size 26. Cuz the order of the letters doesn't matter. vvcvvv -> 0 0 1 ... 5 ...

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

          Cuz the order of the letters doesn't matter.

          You're correct, but can you explain why that is true? On first glance it seems like it would matter as we're removing adjacent characters.

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

            Is it even obvious after many glances? One would be tempted to say so since nearly 5000 people solved the problem but it just doesn't seem like the kind of fact that would jump at you, even if you stared hard enough.

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

              It most definitely isn't obvious to me; even I guessed that it just works during the contest. I believe I would be able to prove it now, but it seems quite annoying.

              Me guessing the solution was the combination of "I had seen similar problems before with similar solutions, this feels correct" and "this is D3C, the solution is probably very simple". Even though guessing isn't generally considered a proper way of solving problems, with strong enough intuition it might be more optimal than proving solutions in modern CF contests.

              Is this a sign that the current problem style is bad? I'm not sure, but this should probably be discussed more.

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

              think of it this way, you can always pair one highest frequency letter with another letter, unless only one type of letter remains(the highest frequency letter will have to border another letter). So the order doesnt matter

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

                But if we consider the test case presented earlier by vgtcross: acbdaeb, we see that the two highest frequency characters a and b turn out to not be adjacent to each other at all. So reducing both their frequencies by 1 is sort of a false move, since a and b can't reduce each other. Sure, you can always reduce the frequency of the highest letter, but it doesn't always end up being reduced with the second-highest frequency letter (which ironically turns out to be the correct greedy solution in the end).

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

                  no, i meant pair (any) of the highest frequency letters at that moment with any other letter adjacent to it. you can always do this until you're left with nothing, or a string with a unique character(so you're not necessarily reducing it with the one with second highest frequency)

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

                I think focusing on the highest frequency letter is more confusing than not : - you can always pair any letter with another letter except if this letter is the only letter.

                Using this fact, the "order doesn't matter" property come in an easier way.

                Then then question is, when do we have letters that are left and the highest frequency letter come in.

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

                  yeah that's it

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

                  This is not true, you need to pick the highest frequency letter, otherwise from aaabc you can end up at aaa, which is a wrong answer.

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

                  That is not what my message above is saying.

                  What it is saying is that you can basically always pick which letter you want and choose to delete it except if its the only letter. It does not say that your choice will be in the optimal answer.

                  So when you find that the letter that you want is indeed the highest frequency letter, you don't have think about IF at any moment, you will not be able to delete it. With the observation above, you know that you will ALWAYS BE ABLE TO.

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

                  That is also not true. Basically you are saying that in abaca, I will be able to pair b and c, delete them and end up with aaa, but that is not the case.

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

                  No, I'm saying that you can pick 'a', 'b', or 'c' and choose to delete it. It will be deleted with an other unknown letter but it is guaranteed that you will always be able to delete the one letter you choose.

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

    А possible logical chain:

    1) In final string you can't make any operation, since it's the shortest possible achievable string.

    2) => In final string $$$s_1 = s_2, s_2 = s_3, \ldots, s_{k-1} = s_k$$$. I.e all symbols are equal in final string.

    3) Quite intuitive thing to do is try to bruteforce that "final symbol".

    4) Then you can see than until there is at least two different letters and at least one "final symbol", than there is an adjacent pair of symbols, one of which is "final symbol" and one of which is not. It's like a simple application of that classic obvious lemma: if there is a binary string with at least one "0" and at least one "1", than there is an substring "01" or substring "10".

    From now it's more or less obvious what's next to do (I believe)

    Steps 1, 2, 3 seems very logical to me. Maybe step 4 can be seen like an "observation", but this "lemma" about "binary string with at least one "0" and at least one "1", than there is an substring "01" or substring "10"" is way too classical, and it is an easily recognizable pattern after you seen this some number of times. So it all comes down to "solve more problems to be able to quickly recognize such patterns", who could have guessed

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

    FWIW, I'd like to point out that the DP approach for C does work, although it's not efficient (time complexity $$$O(n^3))$$$. But solving it using DP in $$$O(n^3)$$$ is still a good learning exercise, as you might find transitions difficult if you are accustomed to thinking about DP problems in a certain manner, owing to the fact that the neighbors are joined together after deletion of inner elements. I suggest people comfortable with DP to try this out.

    For example, you might define $$$dp[i][j]$$$ as the minimum number of characters remaining at the end when we are only dealing with $$$str[i...j]$$$. Then, you might try collapsing the first pair, say starting at index $$$x$$$. However, there's no way to proceed now because $$$dp[i][x - 1]$$$ and $$$dp[x + 1][j]$$$ cannot be combined.

    The Trick

    Submission

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

I wanted help with problem C please, it is failing in test case 2

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

    maybe, show the code could help make the problem more clear?

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

    Well, I read your submission just now. As I'm not a native English speaker, if I say something confusing, please tell me. I thought you use recursion to delete characters until nothing can be deleted. Firstly, even if you writed the code well and didn't get a WA, this code could be made TLE because it's O(n^2). So it's not a correct solution for this problem. Secondly, your strategy of deleting is wrong. Let's think about such a string: "bbaebbaecccccccc". It's length is 16 and the answer is 0. However, your code will give the answer 6, which is wrong. because once it find a pair of different adjacent characters after same characters, it deletes them. For examples, it delete 3rd and 4th characters which are 'a' and 'e'. But it's possible that we don't delete them right now but later. Actually, to reach the answer zero,we delete the middle two chracters each time. So one correct way to solve the problem is to delete the characters which is the most numerous in the string right now with a character different with and adjacent to it. Obviously, when we can't do this, we can print the answer. You can use priority_queue (heap) to do this in O(nlogn). A better way is not to simulate the deletion process, just count the number of each letters and then print the answer, which is O(n). Here is my code: https://mirror.codeforces.com/contest/1907/submission/235898166

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

    What's more, it's usually not a good idea to use vector(bool) due to some historical reasons. Try to use bitset instead.

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

Do you believe light? 你相信光吗?

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

Was this round rated? Why is it showing unrated?

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

Why does my solution give TLE for problem B

https://mirror.codeforces.com/contest/1907/submission/235957135

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

    The statement ans = ans + str[i] takes O(n) time where n is the length of ans so actually your solution works in O(n^2). You have to change it to ans.push_back(str[i[) and it will work fine

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

    ans=str[i]+ans; this operating is costly as every time you add new char at the beginning of the string it takes O(size of string) time. instead of doing this you can insert the char at end of the string and after all the operation just reverse the string 236009502

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

Who understands the pain of not being able to load in 20 minutes at the beginning of the competition? I've never been stuck for so long before.

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

pls explain problem E. Thank you

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

    How I solved it, although I'm not sure if I explain it well enough.

    Hint
    The main idea

    I hope this makes sense, lol.

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

почему рейтинг за раунд не начислен?

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

why didn't the submission 235883526 solution not work for 1907B - YetnotherrokenKeoard (problem B)? was it because of memory copy?

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

why it is so late to publish ratings nowadays?

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

After 10 contests, I'm finally green!

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

wow

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

Good evening, Everyone (including system).MikeMirzayanov I have just recieved a notification regarding my submission number https://mirror.codeforces.com/contest/1907/problem/D for my solution coinciding with others. You can clearly see the name of functions been created to be obvious for the answer and also you can see the trademark of my solution to be genuine on the top. You can verify all of this from any of my submissions from the past few months. You can also go through my style of using the variables and functions from any of my previous submissions. It can be a coincidence as the functions and variables I use are very common among competitive coders but I am sure about my solution being genuine and completely self thought. Thank You
Mukul457 Some of my previous submissions-: https://mirror.codeforces.com/contest/1688/submission/217835352 (8 Aug 2023) https://mirror.codeforces.com/contest/1207/submission/220195657 (24 Aug 2023) https://mirror.codeforces.com/contest/1714/submission/226328908 (2 Oct 2023) https://mirror.codeforces.com/contest/31/submission/228841576 (19 Oct 2023) https://mirror.codeforces.com/contest/1869/submission/222855817 (11 Sep 2023)

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

    [user:MikeMirzayanov][user:Vladosiya][user:pashka] Sir please look into this matter. I didn't expect such a behaviour from you all. It's been so many days, and nothing has been done. The system asked us to post a comment if there is a mistake from your side and it will be taken care of. Please I humbly request you! Thanks Mukul457

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

NIce contest

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

Why in this contest. I had rank 3xxx and got rating 500, but my friend had rank like 11k and got 620 rating ?