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

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

Neapolis University Pafos

Привет, Codeforces!

Серия образовательных раундов продолжается благодаря поддержке программы Computer Science and Artificial Intelligence (CSAI) в Neapolis University Pafos со стипендиями от компании JetBrains.

В 18.05.2026 17:35 (Московское время) состоится Educational Codeforces Round 190 (Rated for Div. 2).

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Задачи раунда будут частично пересекаться с внутривузовской олимпиадой Саратовского ГУ (запланированной на 17-е мая), поэтому если вы студент Саратовского ГУ, планирующий принять участие в олимпиаде, мы просим вас пропустить этот раунд.

Вам будет предложено 6-7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи со мной придумывали и готовили Адилбек adedalic Далабаев, Максим Neon Мещеряков и Александр fcspartakm Фролов. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Я бы хотел поблагодарить тестеров задач: shnirelman, awoo и FelixArg. Ваш фидбэк по задачам нам очень сильно помог!

Наконец, что немаловажно, у нас есть сообщение для вас от наших друзей из Neapolis University Pafos:

Финальный этап приёма на программу бакалавриата BSc in Computer Science and Artificial Intelligence в Neapolis University Pafos уже открыт.

Ключевые даты:

  • Крайний срок подачи заявки: 9 июня 2026

  • Обязательный вступительный тест: 14 июня 2026

Подайте заявку, чтобы получить шанс стать обладателем одной из 40 стипендий JetBrains Foundation, которые покрывают:

  • полную стоимость обучения

  • проживание

  • ежемесячную стипендию

  • визовую поддержку

Подайте заявку сейчас и подготовьтесь до финального дедлайна!

Удачи всем участникам! Я надеюсь, что вы получите удовольствие от решения задач и узнаете для себя что-то новое.

UPD: Разбор опубликован.

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

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

I love you guys

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

Love it!

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

And here we go, $$$6 - 7$$$ problems again...

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

i am lazy

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

不错不错

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

hi

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

Div4 and educational rounds are the rounds we like the most.

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

Hope For Interactive Problems

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

?

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

I bet the hacking phase will be awesome!

Spoiler

GL & HF!

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

Lesssss gooooooooo Educational Round here we go

Must be the water aaaaah Moment

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

hope this contest will be better than previous one:)

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

Educational rounds never disappoint. Time to solve A–B confidently and get humbled by C.

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

Hope this gets me expert

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

Interesting round, except for the fact that I will lose nearly 50 ratings after this round ;). Meanwhile, my friend is going to reach CM...

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

$$$D$$$ was so easy, had no time to solve it.

If only I hadn't gotten stuck on trash can problem $$$C$$$.

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

what's the intended solution for D, am i stupid for using a nlogn solution?

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

    i have O(n) DP-like solution, working from right to left

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

    Its simple DP. You have to compute a helper DP at indices where $$$a_i = b_i$$$, like if you both had watched that episode at that index then how much further segments they can still watch before you find a bad pair. And then use this DP later for smaller $$$i$$$. Sorry if explanation is bad but hope you get the idea.

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

    At each index $$$i$$$, let $$$dp_j$$$ be the number of subarrays ending at index $$$i$$$ in which we've already watched $$$j$$$ movies ($$$j$$$ can be 0). Based on $$$a_i$$$ and $$$b_i$$$, we only need to update a few elements in the $$$dp$$$ array for the current $$$i$$$, and then we add all values from $$$dp_j$$$ to the answer. This can be done efficiently by keeping track of the sum of $$$dp$$$ at each point in time, making it $$$O(1)$$$ for each $$$i$$$ and $$$O(n)$$$ overall.

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

    I think the easy way to think about this is that each $$$(i, i)$$$ determines what we are interested in next in $$$(i+1,i+1)$$$, $$$(i+1, x)$$$ or $$$(x,i+1)$$$. This creates a single outcoming edge. Having this sort of tree structure, you can just DP on it to know where the chain ends if you start in some $$$(1, 1)$$$.

    375107486

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

    Backwards DP. Let dp[k] be max day that Alice and Bob can reach if they enter the current day with k episodes watched so far. For each day i, if a_i = b_i (say =k) then the max day they can reach from state k-1 is the same to max day they can reach from state k, so dp[k-1] = dp[k]. Otherwise, they cannot even progress past the previous day, so dp[a[i]-1] = dp[b[i]-1] = i.

    Answer is sum of dp[0] — i for each i. Time complexity is O(n) for each test case.

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

    You can keep track of valid left points for every point i by storing their mex value if they survive till point i. When entering a position you can create a new starting position. If a[i] != b[i], all left points whose mex value are a[i] or b[i] dies at this point, so you just need to add all left points that are alive at every index i.

    375130209

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

i m so ashamed of india's coders bro . they just wont stop cheating man. I hate my countrymen for this.

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

I got humbled bad man...

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

Had no time to solve E :p

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

.

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

    why so overkill?

    notice that for a given person, we have 5 cases: (1) the optimal p is 0, and optimal c is 0, (2) optimal p is t+d, optimal c is 0, (3) optimal p is 0, optimal c is t+d, (4) optimal p and c are both t+d (5) the optimal uses the raw value of p+c

    what can be done is to sort the values c[i] by the key p[i], and vice versa, then build suffix and prefix minimums on them. this allows us to efficiently query the first 4 cases, by asking for example "what's the minimal p-value amongst all i such that c[i] >= t + d?". you find by binary search the location of first c[i] where c[i] >= t+d, then use the suffix minimum to answer the query.

    for the final case, we can just store a segment tree on the values of p+c, sorted by p[i]. then make a query in the range [t, t+d] for the minimum. why does this work, even though the minimum might use a c > t_c? it works because our other 4 cases will have caught that, so even though p+c ≠ I(p,c), it doesn't affect the answer as it is larger than the actual value and we are taking mins

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

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

In Education round I got educated in problem D

I was trying to write some dp with two kind of DP, while storing next values' index coming from right to left

  • solution if we start here and we watch an episode on this day,

  • solution if we start here and we don't watch an episode here

but got confused in implementing it, I was writing too many if-else

is there a simpler way to code this, or some other ideas ?

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

    Get a dp array at each i where a[i] == b[i] which means the right bound if we have already watched 1..=a[i] movies. The transition would involve cases like the next a[i]+1 in both a and b having the same index or not.

    Then for each starting L, find the next position of 1 in both a and b, if they are the same index, ans += dp[ix] — i, else ans += min(ix_a, ix_b) — i.

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

      thanks, I was writing same and was sure it is correct but I am looking for simpler implementation I guess, because I was not able to simplify it.

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

        Define $$$dp[L]$$$ as the minimum $$$R$$$ such that the subarray $$$A[L \dots R]$$$ is bad.

        The first movie has to be $$$1$$$. Suppose it is present at indices $$$a_1$$$ and $$$b_1$$$. If $$$a_1 \neq b_1$$$, then $$$dp[L] = min(a_1, b_1)$$$.

        Otherwise, $$$dp[L] = dp[a_1]$$$

        How to compute $$$dp[a_1]$$$? Notice that $$$a_1$$$ contains a $$$1$$$, so the first movie that you watch from this point onwards is $$$2$$$, so you locate the next occurrence of $$$2$$$, suppose it is $$$a_2$$$ and $$$b_2$$$. If $$$a_2 \neq b_2$$$, $$$dp[a_1] = min(a_2, b_2)$$$

        Otherwise, $$$dp[a_1] = dp[a_2]$$$

        Submission

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

Can anyone Tell me why it got TLE 375137614 Why O(nlogn) got tle

I was happy until "running on test 15".

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

    If I understood your code correctly, it will TLE in an input of this form:

    n
    [1 1 1 1 1 .. (n/2) times] [2 3 4 5 ... (n/2)+1]
    [1 1 1 1 1 .. (n/2) times] [2 3 4 5 ... (n/2)+1]
    

    Since for each 1 you are going to the next largest integer, this code will take $$$O(n^2 \cdot \log n)$$$ time (for each 1, you are traversing the $$$\frac{n}{2}$$$ list of numbers from $$$2 .. n/2 +1$$$)

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

      I think a tighter bound can be proven (O(n^2)). because for every possible left end point (Say L).we are doing binary search to find first 1 at index >= L (say it's i1) now we will do binary search to find first 2 at index >= i1 and so on. Now the amount of times we will do binary search is O(n) but the runtime of every binary search is O(log f[i])(where f[i] is the number of times element i occurs in the array) so the total runtime of all binary searches for a given left end point would be upper bounded by (sum of log(f[i])) over all i (because we never binary search for the same element again given the left endpoint is fixed) which is log(sum of f[i]) which is O(log n) . So for a given left end point overall runtime is O(n + log n) which would be O(n^2 + n log n) or O(n^2) overall.Reply if anything seems wrong.

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

        I don't quite get how you arrived at $$$\sum_i \log f[i] = \log (\sum_i f[i])$$$. A better argument would be to use the concavity of log function to arrive at

        $$$ \frac{\sum \log f[i]}{n_d} \leq \log (\frac{\sum f[i]}{n_d}) \leq \log(\sum f[i])) $$$

        where $$$n_d$$$ is the number of distinct elements. The last inequality is possible because of the monotonic nature of $$$\log(.)$$$

        From this we get that $$$\sum_i \log f[i] \leq n_d \cdot \log (\sum_i f[i]) \leq n_d \cdot \log n \leq n \cdot \log n$$$ (Since number of distinct elements $$$\leq$$$ number of elements)

        Using this inequality we arrive at the same $$$O(n^2 \cdot \log n)$$$.

        Please correct me if I am wrong.

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

          Oh sorry I forgot to change sum to product there. But i also have another question if we only use the inequality u mentioned on the left side. Then sum of log(f[i]) <= n log((sigma f[i])/n) If we substitute sigma f[i] = n here on right right side something weird is happening. Like Sum of Log(f[i]) <= n log(1) (Got it now thanks)

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

            Even if you use product, I think if you use some bounds from AM-GM, you are likely to get the same bound.

            Secondly, I think it is a slight oversight from my side in using the wrong notation. The $$$n$$$ in the expression should be replaced with $$$n_d$$$ where $$$n_d$$$ is the number of distinct elements. However you can bound it in a similar way (not too hard)

            EDIT 2: Made the necessary changes in the original post

            EDIT: The inequality I'm referring to is Jensen's inequality (https://en.wikipedia.org/wiki/Jensen%27s_inequality). The inequality is right; just an error in notation :)

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

      got it , i just have to store (memoize it) it like {next int,index} so next time whenever i reach i directly call the answer

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

    This is my O(nlogn) solution 375186318

    To handle cases like [1 1 1 1 1 .. (n/2) times] [2 3 4 5 ... (n/2)+1]

    Use: if(a[i]==a[i-1])curr_r = previ_r;

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

Can someone explain where I am wrong in B? Remove all 4s+min((count of 1+count of 3 before last 2),(count of 2 after minimum index of 1 and 3))

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

    idk I did the same sol as u and kept screwing up on test case 2

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

    For this test case 1 1 1 2 2 2 2 2 3 3 3 3 2

    • count of 1 + count of 3 before the last 2 = 7
    • count of 2 after the minimum index of 1 and 3 = 6
    • if you remove first first 3 ones and last 2, cost = 4 and you still get a valid ordering.

    Logically speaking, you are only considering 2 strategies: removing ALL ones & threes, or removing ALL twos. You are not considering any hybrid strategies.

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

      I took a slightly different approach and considered the count of 2s remaining after when deciding which path to take 1. remove all the current two 2. remove all the ones + threes before

      for _ in range(int(input())):
          s = list(map(int, input()))
          n = len(s)
          
          removed = s.count(4)
      
          suffix2 = [0] * (n + 1)
          for i in range(n - 1, -1, -1):
              suffix2[i] = suffix2[i + 1] + (1 if s[i] == 2 else 0)
      
          count = 0 # counts 1s and 3s
           
          for i in range(n):
              num = s[i]
      
              if num == 4:
                  continue
      
              elif num in (1, 3):
                  count += 1 # 12 , 32
      
              elif num == 2 and count > 0:
                  if suffix2[i] > count:
                      removed += count
                      count = 0
                  else:
                      removed += 1
      
          print(removed)
      
      • »
        »
        »
        »
        4 месяца назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится 0 Проголосовать: не нравится

        Consider the test case: 1 1 2 1 1 1 1 1 2 2

        In this test case your code will remove the first 2 ones and last 2 twos with a cost of 4. Whereas you could've just removed all 2's.

        I think you are just missing the case when you have to remove all the twos. Another check outside the loop might work.

        EDIT: The additional check doesn't work.

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

          thanks lol; just checked the sol and realized where i went wrong. better approach would've been just to remove all 4s, then look at the string every time there is a three/one to check if its worth keeping the previous chain of 1/3 or the chain of 2s instead (persistent count that is never reset), adding one to account for the 1/3 just read. At the end you add a final check (like u mentioned) for cases where there are no 1/3.

          #B. Digit String
          '''
          for _ in range(int(input())):
              s = list(map(int, input()))
              n = len(s)
              
              removed = s.count(4)
          
              suffix2 = [0] * (n + 1)
              for i in range(n - 1, -1, -1):
                  suffix2[i] = suffix2[i + 1] + (1 if s[i] == 2 else 0)
          
              count = 0 # counts 1s and 3s
               
              for i in range(n):
                  num = s[i]
          
                  if num == 4:
                      continue
          
                  elif num in (1, 3):
                      count += 1 # 12 , 32
          
                  elif num == 2 and count > 0:
                      if suffix2[i] > count:
                          removed += count
                          count = 0
                      else:
                          removed += 1
          
              print(removed)
          '''
          
          for _ in range(int(input())):
              s = list(map(int, input()))
              n = len(s)
          
              # basic idea is first remove all fours, then look for the longest sequence of twos follows by 1/3; not the other way arround as it would break the rule
          
              count = s.count(4)
              seq = []
          
              for i in range(n):
                  if (s[i] != 4):
                      seq.append(s[i])
          
              only2 = 0
          
              best_seq = 0
          
              for i in range(len(seq)):
                  if seq[i] == 2:
                      only2 += 1
                  if seq[i] == 1 or seq[i] == 3:
                      # adds one to simulate adding a 1 or 3 after a chain of twos -- 22221 (which is fine)
                      # checks if the current chain of twos is worth more then the previous chain or twos + threes
                      best_seq = max(only2, best_seq) + 1
          
              best_seq = max(only2, best_seq)
                      
              print(n - best_seq)
          
    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Can you explain your logic?

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

        Its obvious that we need to remove all the 4s. Now iterate from left to right and consider we encounter a 1 or 3 at the ith position. We have two choices from here:

        • Suppose I choose to keep this 1 (or 3). Then I will be forced to remove all the 2s to the right of ith position. Once I remove all the 2s, it automatically becomes a valid configuration. The cost for this is $$$\text{count of (1s/3s)} + \text{suffix_count[i]}$$$
        • The other choice is to remove the 1 (or 3). Removing this single occurrence is added to a counter. Immediately removing this character doesn't make it a valid configuration, so we have to continue this process until the end.

        You can come up with a loop invariant to show that for every iteration i, once we remove all the prefix 1s and 3s, removing all the suffix 2s from here is a valid configuration. This is required to justify the expression ans = min(ans, cur + fours + twos[i]);

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

    I used the same idea and got WA2 :(

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

anyone used DP for B or just dump me..

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

B is so hard :/
i didn't see condition where numbers are between 1 and 4, so i solved for 1..9 (

But i really liked problem E, although i did ~200 lines implementation xD

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

thanks for useful samples in C!

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

ABC is easy, D is hard asf.

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

Relatively simple E, just ran out of time smh

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

the worst “B” in ever for me

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

In 375138399, I got a mysterious Compilation Error with error message

g++.exe: fatal error: cannot execute 'C:/Programs/gcc13-64-winlibs/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/as.exe': CreateProcess: No such file or directory

I submitted basically the same code 3 minutes after and got AC: 375139568

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

375122442 Can any one help get a test case in which this fails? Main idea is to count at each step if I am encountering an 1 or 3, I am checking count of 2 and count of (1 + 3) till that point and adding the minimum to my answer and discarding all counts of 1 , 2 and 3.

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

Can someone see my profile and say how do I practice I am stuck on div2 contests sometimes I do 2 sometimes 3 I want to reach level of 4(mostly) how do I practice I prefer solving codeforces problemset no tags as per choosing rating what do I choose Thankyou:)

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

How to get rid of huge constant in E?

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

Anyone else felt C easier than B?

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

anyone felt D was harder than E?

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

There is a $$$O(n\log n)$$$ solution for D with Fenwick Tree which can be optimized to $$$O(n)$$$.

At each index $$$i$$$, if $$$a[i]==b[i]$$$, it can either extend all valid segments ending at $$$i-1$$$ that have watched until exactly episode $$$a[i]-1$$$, causing both Alice and Bob to now watch episode $$$a[i]$$$, or extend all valid segments ending at $$$i-1$$$ that have watched until some episode other than $$$a[i]-1$$$, but both Alice and Bob do not watch the current episode.

If $$$a[i]\not=b[i]$$$, then any valid segment ending at $$$i-1$$$ that have either watched until exactly $$$a[i]-1$$$ or $$$b[i]-1$$$ cannot extend past $$$i$$$, since only one of them would be watching the episode. All other valid segments can be extended, provided neither $$$a[i]$$$ nor $$$b[i]$$$ are equal to 1.

With a Fenwick tree, we can maintain the number of valid segments ending at $$$i-1$$$, where the next episode to watch is $$$k$$$ for $$$1\leq k\leq n$$$, and update the counts of valid segments using point update, and doing a range sum for $$$[1,n]$$$ for each index. This leads to an $$$O(n\log n)$$$ solution. Submission: 375183000

We can observe it's not necessary to maintain a Fenwick tree. We can just use a $$$count$$$ array. The only change is we now have to keep track of $$$total$$$ — the total number of active, valid segments ending at $$$i$$$. This reduces the complexity to $$$O(n)$$$. Submission: 375184626

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

Who else solves E in $$$O(n+q+V)$$$ ?

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

Hi

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

why always there is an overflow hack and it is not in main tests in edu rounds ?? T__T why even keep 1e9 constraints on values :( just int <--> long long causing bug hurts ::( BledDest

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

3 problem was something difficult to understand

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

Why ten hours for system testing + edi?

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

After 35 contests and over 220 days practice I finally reach master again

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

I participated as rated, but this contest is showing in my unrated contests. Plus there is no change in my rating.Why?

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

Weak pretests in E.

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

when will the contest rate us (please forgive my bad english)

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

Hope I will reach expert after this contest!!

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

wheres the editorial ganggg

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

Does anyone know why is it taking so long to update the ratings and why is it showing in unrated contest list in profile -> contest??

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

why long ahh queue or is some testin still going on

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

I solved 2 questions in this round but my rating drops 33 why? I cant get this actually I am new to this can anyone explain why this happens morever I submitted solution in single attempt only

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

I understand the concern regarding similarity. I solved the problem independently during the contest using the standard two-pointer approach commonly used for this type of problem. I did not intentionally copy any solution. I will also make sure to use a more distinct coding style/template in future contests. Thank you.

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

Respected Team members,

As my solution was found similar to some other contestants solution, I would like to say that i solve all my questions using the preexisting self made boilerplate in each and every contest. it seems the format was very similar of both the solutions but i guarantee you that there was no connection between both the solutions and i wrote mine the way i usually write them. Please check this issue and a response on this issue would be helpful. And the logic was pretty straightforward for the question as it was just counting which section of either (1's and 3's) or 2's will be the least plus the total nos of 4 to stop the formation of 12, 32 and any nos including 4.

bada_bhondu

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

Hello respected members , I received a notification saying I'd violated a rule in my submission of 2230C - Arrange the Numbers in a Circle . Could I please talk to one of the organizers/admins to appeal against this violation . I havent committed any form of plagiarism and had structurally broke down the questions into 2 cases when we had one vs multiple cards of frequency > 1. I did some trial and error and derived the exact formulae for both cases and implemented it. I did use a standard template which wasnt similar to some of my previous submissions which was a mistake on my end but the implementation was purely my own. If needed I can provide screenshots of the code in my ide or any other form of legitimacy. Could someone look into this it'd mean a lot thank you !

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

easy round!

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

BYE BYE XVIII

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

I solved 4 questions, but it is still showing skipped on my end and my rating has not been updated.