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

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

Привет, Codeforces! 👋👋👋

Во Jun/17/2025 17:35 (Moscow time) начнётся Codeforces Round 1032 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 8 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингом до 1600. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

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

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

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

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

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

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

Хочется выразить слова благодарности:

Всем удачи! 🔥🔥🔥

Разбор!

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

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

hoping to get positive delta!!! (from a warrior race)

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

Hope this will be a great round :XD

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

ROAD TO EXPERT!!

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

Only two div. 3 people tested?

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

hope to reach $$${\color{green}{pupil}}$$$

$$${\color{cyan}{and}}$$$ $$${\color{orange}{good}}$$$ $$${\color{red}{luck}}$$$ $$${\color{purple}{everyone}}$$$ $$${\color{blue}{!!!}}$$$

P.S: not today :(

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

hoping to get positive delta!!! (Recover from last Div 2):)

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

Hoping to reach a specialist in this contest.

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

Hoping to solve 5 questions for the first time.

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

Score distribution?!?!?

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

i hope it goes well

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

Omg finally my first unrated div3

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

Hope to become div 3 unrated in this contest

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

hope to reach pupil

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

As a tester, I wish you all good results on this great round!

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

Hoping to reach pupil this time

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

good luck everyone

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

I just want 5 AC in this contest.

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

expect to expert

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

The internet in Iran is terrible due to the conditions I hope I don't have any problems posting.

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

When I tried to upload my solution to the 3rd problem I got a "Sorry, you have been blocked" message. I tried and it is now blocking sending in solutions for previous competitions too. I tried to find info on the "help" page, but nothing useful. Anyone know whom to write to, and/or why this would happen?

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

Contest with perfect level wise problem

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

Good contest, had fun!!

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

how to solve D

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

    Use bubble sort , one thing i found more useful is

    normally we say that bubble sort takes n^2 time complexity but in real it takes max (n)*(n+1)/2 in question n was max 40 so for the both the arrays this will pass

    initial i thought that 2 (for both array )* n^2 (i assumed that bubble sort is n^2) operation will need and i was confuse to solve it later i realized bubble sort requires less then n^2 operation

    it is very very good problem , you can check my submission

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

did anyone else do a randomized solution for $$$E$$$?

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

such a boring and uninspiring round. i felt like i was doing a codechef round smh. had the solution for F just couldn't be bothered to write it. i really dont know how any problems from C-F were accepted as actual problems, really disappointing

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

HOW TO SOLVE C?

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

Beautiful problem H!

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

Was it just me or was C more difficult than D and E...

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

nah top 100 div 3 in this contest, 70 cheaters, 30 smurfs

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

I think I won't be able to participate in the codeforces contest until further notice The internet speed here is terrible and it takes 5 minutes to get to any page (due to the war) Goodbye codeforces!

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

nah top 100 div 3 of this contest, 70 cheaters, 30 smurfs

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

Can E be solved without Dp If not can u explain the DP solution Much love yall

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

hope all AI-cheaters will get banned

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

Couldn't figure out why this fails on test2 in F: https://codeforces.me/contest/2121/submission/324900759

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

Is there a solution to E without dp ? If so please explain it If not can u explain the dp solution

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

    Not sure what the dp solution is. I did it as follows:

    Start comparing digits of l and r from most significant to least significant and find the longest common prefix. The number x will need to have the same digits here. If the length of this common prefix is p, then 2*p is added to ans.

    Now for 1st mismatch in digits of l and r, if digit.r > digit.l + 1, then we can construct x with no more common digits to l and r. In this case 2*p is the final ans.

    Otherwise, there are 2 cases:

    1. assign digit.r to x. For all the immediately following 0's in r, x's digits will also be 0. If number of following 0's are q, then q+1 is added to ans.
    2. assign digit.l to x. For all the immediately following 9's in l, x's digits will also be 9. If number of following 9's are r, then r+1 is added to ans.

    So ans = 2*p + min(q+1, r+1)

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

    A purely greedy / constructive solution in O(number of digits): 324911040.

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

    I solved it without dp It wasn't a hard problem but there were a lot of small points! I hope this code helps you:

    int ans=0;
    bool khosh=false;
    
    for(int i=0; i<n; i++) {
      if(res1[i]==res2[i] && khosh==false) {
        ans+=2;
      } else if( abs(res1[i]-res2[i])==1 && khosh==false) {
        ans+=1;
        khosh=true;
      } else if( res1[i]=='9' && res2[i]=='0' ) {
        ans+=1;
      } else {
        break;
      }
    }
    

    n is the number of digits and res1, res2 are the input numbers that I received as strings

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

    see my Solution Purely Greedy we st

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

    Here is my solution using DP. I am not sure if it is optimized properly, but it got accepted.

    The goal is to minimize:

    f(l, x) + f(x, r)

    We solve this using digit DP. The DP state tracks:

    • The current digit index
    • The digit chosen at this position
    • The state of x relative to l and r

    DP State Definition

    dp[i][d][s]: Minimum matches when

    • i: Current digit position (from most to least significant)
    • d: Digit placed at position i
    • s: Current state of x:
      • 0: Equal to l only
      • 1: Equal to r only
      • 2: Equal to both l and r
      • 3: Strictly between l and r

    Base Case

    At the most significant digit p:

    • If l[p] == r[p], we initialize dp[p][l[p]][2] = 2
    • If l[p] != r[p], we initialize:
      • dp[p][l[p]][0] = 1
      • dp[p][r[p]][1] = 1
      • For digits in (l[p] + 1, r[p] - 1), set dp[p][d][3] = 0

    Transitions

    Loop from position i = p-1 down to 0, and try all digit/state transitions:

    1. From state 0 (equal to l only):

      • Stay in 0 if current digit is l[i] (add +1)
      • Move to 3 if digit > l[i] (add +0 or +1 if digit also equals r[i])
    2. From state 1 (equal to r only):

      • Stay in 1 if digit is r[i] (add +1)
      • Move to 3 if digit < r[i] (add +0 or +1 if digit also equals l[i])
    3. From state 2 (equal to both l and r):

      • If l[i] == r[i], stay in 2 and add +2
      • Otherwise:
        • Move to 0 if digit is l[i] (add +1)
        • Move to 1 if digit is r[i] (add +1)
        • Move to 3 if digit is between (add +0)
    4. From state 3 (strictly between):

      • Any digit is allowed
      • Add +1 if digit matches l[i] or r[i]

    Final Answer

    Minimum of all values dp[0][d][s] over all digits d and states s

    Implementation Code: 324944536

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

Problem G : codechef

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

Had a lot of fun with problems F, G, and H. Thank you!

On a separate note, my solution to H was with lazy segment tree. Could somebody please tell me a cleaner idea? And, apart from that, my G uses three segment trees (well, four to be precise, but that was because I went crazy there for a sec), so a cleaner idea would also be appreciated.

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

    I did G as follows:

    Define a function g(l, r) as the minimum of frequency of 0 and 1 in s[l...r]

    f(l, r) + g(l, r) = r-l+1 It is easy to find summation of f(l, r) $$$-$$$ g(l, r) over all (l, r). For the given string, keep a prefix array p with p[i] = number of 0's in s[1...i] $$$-$$$ number of 1's in s[1...i].

    f(l, r) $$$-$$$ g(l, r) = abs(p[r] $$$-$$$ p[l-1]).

    The rest is just computing sum of abs(p[x] $$$-$$$ p[y]) over all (x, y) which can be done by sorting p.

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

    For problem H: You can extend standard LIS algorithm for this question whose implementation is very simple (just 3-5 lines of code using multiset).

    Submission link: https://codeforces.me/contest/2121/submission/324947588

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

    I have a divide and conquer solution for G

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

      My solution was fully inspired by yours — I learned a lot just by trying to understand it.
      But I didn’t fully understand what’s actually going on in the divide and conquer part.

      But, but, but... I think I’ve come up with a version that’s better — or at least easier to understand !

      You used this formula:

      max(a, b) = (a + b + |a - b|) / 2

      That gave me an idea — why not just start by adding the total sum of all possible substring lengths, which is:

      n * (n + 1) * (n + 2) / 6

      Then I realized, we just need to add the sum of all absolute differences of the prefix balances, which reminded me of a classic LeetCode problem —
      “Sum of Absolute Differences in a Sorted Array.”

      So even though I didn’t directly understand your approach, the idea you shared still helped guide me in the right direction. Thanks for that!

      Here’s my code: 325253633

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

I bricked problem F with sparse table and binary search... Turns out I don't have enough time sadly.

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

For problem F, can someone explain why am I getting TLE with this code though I used binary search?

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

why does this approach for F not work? what to change in this to make it work? Submission

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

Problem G was nice!!!

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

The first div 3 contest that went good : )

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

me solving F be like I need sparse matrix no wait there is no need.no wait I need it,ohh yeah it can be done without spare table

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

why the contest rating have not made any changes in already existing rating of mine? is the issue with someone else as well, it is not even showing in the graph as well

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

Some of these cooked me ~

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

Can anyone help me with C ?

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

    The idea is this: consider the maximum value in the grid, call it $$$X$$$, and look at all of the cells which have value $$$X$$$. If it is possible to choose a row and column that encapsulate all of these cells, then that becomes the optimal choice and the answer is $$$X - 1$$$. Otherwise, the answer is $$$X$$$.

    There are a few ways to do this; the important part is NOT writing a $$$O(N^2M)$$$ or $$$O(NM^2)$$$ solution. If you do, you'll TLE to test cases with large $$$N$$$ or $$$M$$$, respectively.

    My solution takes advantage of one property: assume that we can encapsulate all of the cells containing the value $$$X$$$. Pick any one of these cells (it doesn't matter which) — we will have to use either its row or column in the optimal choice. Assume we use its row; consider the set of cells with value X not on this row. If they all belong on the same column, it works. Otherwise, it doesn't. Swap the rows and the columns for the other case. Since there are at most $$$NM$$$ cells containing the maximum value X, this solution runs in $$$O(NM)$$$ time. You can check my solution for implementation.

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

Pretest case should be more strong enough for problem C.

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

Hi Folks,

This is my first contest ever and at the moment I am unrated. I solved 6 out of the 8 questions in this round. Can I expect some kind of rating after this?

Thanks

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

Such a nice contest it was in terms of the problems given. Hopefully, I also got what I aimed for.

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

hoping to get positive delta!!!

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

My pF got hacked (unordered map) QAO

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

here after long time , has cf changed something? i am not able to view other code for submissions.

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

I think the two hacks I made on C were test cases 9 and 10... and holy moly so many people got TLE on 10. I'll take it :)

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

when is the editorial coming?

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

voventa why no thanks to 74TrAkToR?

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

when will we get tutorials?

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

when will we get the tutorials?

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

Competitive Programming in 2025 – A Broken Race?

Two coders. Same leaderboard.

  1. One writes 200+ lines, fails test case #83, debugs, and finally ACs.
  2. The other pays ₹25 and submits instantly.

Result?

  1. Both rank above you. One earned it.
  2. The other bought it.

The problem: CP is turning into a “pay-to-win” model.

Impact:

  1. Honest coders feel demotivated
  2. Rankings lose meaning

The spirit of CP is at risk !!

The ask: Platforms like Codeforces, CodeChef, LeetCode must act fast. Cheating isn’t just breaking rules — it's breaking the community.

Let’s keep CP clean. Let’s keep it fair. Agree or disagree?

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

Простите за не доумение я сам в шоке что получились такие совпадение но Najibullo_prog это хейтер он создал аккаунт из моего имени не знаю что он что то решал но я сам в почти последних минут решал эту задачу думал эту будет не челевечно если мне даст большой минус и блок всех задач иза одних совподений а NAZIROV я сним знаком он решил задачу сам и бысрее чем я тоже решил после него. простите за недоумение я иза совподений вообще изменил стиль писание кода

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

Appeal for "My solution 324842333 for the problem 2121C significantly coincides with solutions of 1 Other", I was quite surprised and shocked seeing the mail, totally unexpected. I had submitted my code at 8:45 (IST) and then continued to code with my other problems and finishing the final one at about 10:07 (IST), All my solutions have a laid out consistent writing style, with significant inspiration from youtube tutorials and video lessons. I still can't figure out how my this other person, who submitted the problem about more than an hour later, got it same as mine, even though his solution looks like it's been directly off GPT. Please take a look at it and provide a solution. Thank you for your time and understanding.

»
17 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Hello Codeforces Administration,
I am writing regarding the plagiarism flag on my submission 324828250 for problem 2121E, which was found to be similar to a submission by user Noodl3.

The reason for this similarity is that the problem is a standard application of "Digit Dynamic Programming". The solution follows a very rigid and well-known template that is publicly taught in numerous competitive programming tutorials and resources.
This standard template dictates the entire recursive structure, the state variables, and the transition logic. When two programmers independently apply this public template to the problem, the resulting code will naturally be almost identical in structure.

The similarity is a consequence of the problem having a single, standard solution path, not of any collaboration. I can assure you I have no connection to Noodl3 and wrote my solution entirely on my own.

I am happy to provide any further clarification needed to resolve this. I take the rules of fair play on Codeforces very seriously and thank you for investigating this matter.

324828250

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

D ,1709... I wanna what is the 1709 meaning;I am just interested in that