awoo's blog

By awoo, history, 14 months ago, translation, In English

Neapolis University Pafos

Hello Codeforces!

The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos.

On Feb/27/2025 17:35 (Moscow time) Educational Codeforces Round 175 (Rated for Div. 2) will start.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 or 7 problems and 2 hours to solve them.

The problems were invented and prepared by Adilbek adedalic Dalabaev, Ivan BledDest Androsov, Maksim Neon Mescheryakov and me. Also, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Big thanks to the tester shnirelman for his valuable advice and suggestions!

Good luck to all the participants!

Our friends at Neapolis University Pafos also have a message for you:

Admission to the Computer Science and Artificial Intelligence bachelor's program at Neapolis University Pafos is open!

The JetBrains Foundation supports this bachelor's program and offers 15 fully funded scholarships for the most talented applicants. The scholarships cover tuition, accommodation, medical insurance, visa fees, and pocket money (€300 per month).

Learn more here →

First admission round:

  • Application deadline – April 23, 2025
  • Entrance test – April 27, 2025

UPD: Editorial is out

  • Vote: I like it
  • +61
  • Vote: I do not like it

| Write comment?
»
14 months ago, hide # |
Rev. 6  
Vote: I like it +10 Vote: I do not like it

Good luuuck Everyone

»
14 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Upvoted.

»
14 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Why testers are not tagged in educational round announcements?

»
14 months ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

Good luck to all participants also. Have fun and rating increasing!

»
14 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

I'm scared to participate when I see 'Educational Codeforces Round'

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

BledDest problems always make me curious 🔥

»
14 months ago, hide # |
 
Vote: I like it +131 Vote: I do not like it

As the name of the round, I hope the problems are good

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I am stuck in newbie for long days. How should I practice to do better? Need suggestion plz

»
14 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Good luck everyone. I'm for sure gonna break 1600.

»
14 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Just curious, why are there less registrations for a Div 2 contests than a Div 3 contests ? Is it because the problems in a Div 2 are harder than Div 3 contests ?

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    *Large amount of user are newbie, pupil, cyan, as well as a large amount of people attending here. *Below expert, most user try to not miss the div 3 contest. *Above specialist people do div 3 to get self satisfaction or fast solving practice. *... *...

»
14 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I misread (or more like partially read) problem B and I didn't know that the robot stops if it has completed all commands and it's not at 0... I encourage people to read carefully...

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Monocarp should get friends that want to share pizza with him too

»
14 months ago, hide # |
 
Vote: I like it -75 Vote: I do not like it

cp is dead for people rated less than 2100. GPT is solving D in almost all div2s.

»
14 months ago, hide # |
 
Vote: I like it +47 Vote: I do not like it

HORRIBLE problemset (A-D) were too easy and then it's Div 1 only.

»
14 months ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

for problem E

let $$$u$$$ be the number of 0s in a substring, $$$v$$$ be the number of 1s

then one of two must be true for player 1 to win:

$$$u = 3v-1$$$ or $$$u \ge 3v+2$$$

is this a sufficient enough condition or am i wrong (i havent implemented yet so i dont know)

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yes

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    I think there were cases for each modulo 4 and for each you see the difference between the number of 0s and number of 1s, for example for multiples of 4 i wanted to see how many j<i such that pref[j]-3*j<=pref[i]-3*i+1 and (j-i)%4==0 and you do that with multiset, unfortunately didn't have time to implement

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    seems to ac surely it wont get hacked

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Could you please share your thought process and how you came to this conclusion?

    • »
      »
      »
      14 months ago, hide # ^ |
       
      Vote: I like it +30 Vote: I do not like it

      initial observation: player 2 should never pick 11 because it would mean less 1s for player 2 and more 0s for player 1 > player 2 must always pick 01

      which also means every cycle (2 turns): three 0s and one 1s must be removed

      let's just assume theyre 2 continuous blocks

      then player 1's goal is to just survive as long as possible

      if it's (3u,1u) then player 2 wins (3u 0s, 1u 1s)

      (3u-1, 1u) then player 1 wins by stopping player 2 from making the uth move

      any lower and player 1 will die before then

      if it's (3u+1, 1u) then player 2 wins because we're missing a 0

      if it's (3u+2, 1u) then we can make the move and let player 2 run out of 1s

      any higher and we have even more options

      but for multiple blocks (btw there must be an even number of blocks due to the whole substring being cyclic part) you can get something like 0101010101 where you have more than two 0s but you cant do anything as player 1

      (or can you)

      because turns out, that case had been losing the entire time (due to there not being enough 0s)

      with u 1s, it can only prevent player 1 from selecting anything up to u 0s, but we have at least 3u-1 so we always win (pretend u = 0 doesnt exist)

      so that would mean any number of blocks of 0s and 1s would function the same as just 2 blocks

»
14 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Samples are so weak :( In previous rounds samples are not as weak as this one.

»
14 months ago, hide # |
Rev. 2  
Vote: I like it +18 Vote: I do not like it

The round was interesting. Problems were cute in contrast to what can often be found in these Edu rounds. Great job!

  • A: decent mathy A, needed to think a bit, not just guessing.
  • B: kinda boring problem, just implementation
  • C: great binary search problem, haven't seen this in a while in official rounds
  • D: cute graph problem, however, either I was lucky or it was a bit too easy for D
  • E: I was thinking a lot. However I did not manage to even complete a math solution for it. It was definitely beyond my reach at this point (even my range + 200 I think).

Overall, ABCD were nice but quite standard. So one of the results of such standard problem set is that LLMs solve it in 17 minutes, as this Beserker69 cheater did.

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +9 Vote: I do not like it

    do yk if the cutting-edge AI models were able to solve $$$E$$$?

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +6 Vote: I do not like it

    The same account got to 34th place in the last div3 also by cheating, that is crazy

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    hey can you tell me the approach for problem c, can you tell me what would teh valid segments , in fourth test case , which yield 4 as the maximum penalty?

    • »
      »
      »
      14 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      also it would be great, if you could tell which type of problems and concepts should I practcice to become bettern in these type of problems.

      • »
        »
        »
        »
        14 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        I can't recommend more the wonderful ITMO pilot course in the Edu section here at Codeforces (specifically two pointers and binary search topics). I was only able to relatively quickly solve C because I solved the binary search section there.

        Idea in C is binary search for answer. Refer to the second step in the ITMO Edu course in binary search section.

  • »
    »
    14 months ago, hide # ^ |
    Rev. 5  
    Vote: I like it +1 Vote: I do not like it

    IG solution to ai generated can be nlp combined with clustering techniques , seen a lot of similar patterns in codes(lengthy and senseless) while hacking d.Also we can add ai agents to create various solutions ourselves using different llms with different prompts(whatever cheater can use to avoid skip).This would detect many cheater or atleast it will delay their submission.Lets deal AI with AI,Also we can create a knowledge base of each user , To keep track of their coding style. MikeMirzayanov

»
14 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

was c really that easy??I am so stupid to waste to much time on c,releasing in last 10 minutes that d was doable by me if there was more time remaining :(

»
14 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

as soon as i hear 'min the max' or 'max the min', binary search on answer is go to idea!

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I originally tried to solve C by first marking the k largest blue tiles as visited and then for all the other blue tiles checking by size, if it is possible to choose either of the nearest visited blue tiles to the left or right by checking the max red tile in each segment that would be painted (with a max segtree) and checking if it the cost for painting the smaller of the red tiles would increas then answer. Does anyone know why would this greedy approach fail or if anyone solved it using a segtree?

308146343

  • »
    »
    14 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it
    Well, hello! :-)
    Eager algorithm you described should be correct.
    Got it working myself, and i received ac: [submission:308133021]
    Only difference in my implementation was that instead of the k-th largest blue and a segment tree,
    Visibly, i used binary search to find the optimal value,
    Apart from that, i applied the same greedy approach for coloring.
    
  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    I was on the same track, only difference was that I was using a Sparse Table to compute the minimum among ranges. While implementing this I thought of a condition where it will fail so dropped this approach, don't remember the condition now.

    I should have thought about BS first, I might be retarded.

»
14 months ago, hide # |
Rev. 3  
Vote: I like it +2 Vote: I do not like it

In problem C how is it possible to paint 4th sample to get final penalty=4?

10 2
BRBRBBRRBR
5 1 2 4 5 3 6 1 5 4
  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +7 Vote: I do not like it

    you dont need to return the total penalty, you just need to return the maximum penalty out of all incorrectly painted cells

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    Answer
  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    ye i too solved C for the sum of total penalty of all cells that are painted the wrong color. then why my code gave 5 for the 4th test case, i re-read the statement and it was clearly mentioned in bold letters maximum

    i wanna die

    • »
      »
      »
      14 months ago, hide # ^ |
       
      Vote: I like it +4 Vote: I do not like it

      If you really solved finding sum instead of maximum, I think you should be proud of yourself instead. Seems insanely complicated considering the constraints.

      • »
        »
        »
        »
        14 months ago, hide # ^ |
         
        Vote: I like it +1 Vote: I do not like it

        https://mirror.codeforces.com/contest/2070/submission/308178020

        dont know if this is correct, but the complexity is nlogn

        can any pro coder check the code and confirm please, i'll be greatful

        • »
          »
          »
          »
          »
          14 months ago, hide # ^ |
           
          Vote: I like it +1 Vote: I do not like it

          First of all, if the string starts with some RRRs you are adding them to sum, and trying to repaint them later.

          1
          7 1
          RRRBRRR
          2 2 2 100 2 2 2
          

          prints 6.

          Then for sum, it's very knapsack-like, I can imagine only $$$O(nk)$$$ DP[i][k], should be possible to craft a failing test for greedy solution.

        • »
          »
          »
          »
          »
          14 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          Your solution is trickier than it looked initially, but here is example:

          1
          7 1
          BRBRBRB
          5 1 2 3 2 1 5
          

          prints 8, while we can paint entire string and get 5

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        Solving for sum is actually complicated as it turns out, though it is very much solvable given that you know the trick to do so, and it's a fun exercise to try out. Here's a hint to get you started:

        Hint
»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

A & B were a little tricky! Fun problems

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone tell the general idea for C? I got that binary search will be applied , apart from that what was the intuition?

  • »
    »
    14 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +2 Vote: I do not like it

    Given a maximum penalty you can take, what is the minimum number of operations you will have to do? You wouldn't want to touch reds having greater than that penalty. And you would definitely want to paint the blue which have penalty greater than that penalty. So start with such a blue and keep painting till you get such red. Count this as 1 operation of paint. Repeat the same process for all such blues. If number of paint operations is <= k, then we can paint with this maximum penalty & we should search for lesser penalty. If not, it is not possible to paint and we should increase the penalty.

»
14 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Kindly help why the code in Python did not pass. Same code worked for C++ thing.

Problem: https://mirror.codeforces.com/contest/2070/problem/C

C++ Submission after contest: https://mirror.codeforces.com/contest/2070/submission/308176980

Python Submission within contest: https://mirror.codeforces.com/contest/2070/submission/308170127

»
14 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Even though I'm a pupil, I managed to solve D on time. It was my first graph problem solved during the contest. I feel so happy even though, I guess, D was a pretty simple graph exercise in comparison to others. Overall I liked this contest (I'm so dumb for registering unrated... I thought I'd perform worse than I usually do, and suddenly I'm solving D.) Anyway, thank you for the contest. :D

»
14 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

For E problem i thought the following If a string has size 'n' then it has a maximum limit of 1's it can have. if the count of 1's increases then player A loses.

Example:

n = 2 : 00 is the only string so no 1's should be present

n = 3 : 001, 010, 100 are possible so only one 1 is allowed

n = 4 : so i need to choose 2 0's in the first move so the remaining 2 can be 00,01,10,11 and among these only 00 is when player B fails and player A wins so again no 1's allowed

.

.

.

based on this logic I initialized an array 'cap' such that cap[i] is the maximum 1's possible in a string of length 'i' such that player A is guaranteed to win.

But I couldn't implement it in optimal complexity. O(n^2) is the simplest way but how can one do it optimally. Just the counting part is similar to sliding window problems but also including length constraint makes it harder.

Any approaches or similar problems?

My submission https://mirror.codeforces.com/contest/2070/submission/308163978

  • »
    »
    14 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it +3 Vote: I do not like it

    I was thinking along the similar lines but realized that it will be difficult to optimize, I then thought of doing a trick like we use to solve problems like "How many subarrays have sum = k", we have some kind of map that we keep updating and that information is used to count all the subarrays that end at the current index. One other thing to realize was for a substring to be winnable by 1 player

    cnt0 >= 3 * cnt1 + 2 or cnt0 == 3 * cnt1 - 1
    

    Since we have two variables here, we need to find some combination of these two variables that we can store in map. With little organization we get, 0 >= 3 * cnt1 - cnt0 + 2 or 0 == 3 * cnt1 - cnt0 - 1

    Here, 3 * cnt1 - cnt0 can be stored in a multiset for each index, Total substring which satisfy that end at index i is the sum of

    a) count of elements in multiset with value 3 * cnt1 - cnt0 - 1
    b) sum of count of elements in multiset with value greater than 3 * cnt1 - cnt0 + 2, (will need policy based ds).
    

    Solution: https://mirror.codeforces.com/contest/2070/submission/308175382

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

for problem C initially my brain interpreted that in one operation u have to color exactly two cells blue(i don't know how i read that) and later on writing a dp solution and testing the testcases i understood my error.

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

A Good contest on your Birthday feels nice :)

»
14 months ago, hide # |
Rev. 2  
Vote: I like it +5 Vote: I do not like it

How to solve problem C if you had to find the minimum sum of penalties? What will be its time complexity?

I misread and tried to do a prefix sum solution: ((-1 * points) for red if painted and (1 * points) for blue if painted) and tried to get the maximum amount of points (then I will subtract them from the sum of the blue points (sum of their penalties) to get the final penalty.)

However, I don't know how to check if an subarray I counted before isn't containing any elements of another subarray I counted. Is there a way to write code for sum of penalties?

  • »
    »
    14 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    I also misread the problem and tried solving for that variation. I came up with a soln.

    You multiply all the red cells by -1. Then use the k maximum subarray sum algorithm and subtract the sums of all the k subarrays returned from the algo from the total penalty before applying any operation.

    Link for the algorithm

    • »
      »
      »
      14 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      Their max k subarray sum algorithm isnt even correct btw

      It would find the wrong sum for this case (k = 2):

      33 -22 33

  • »
    »
    14 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +4 Vote: I do not like it

    multiply all red penalties by $$$-1$$$ -> the result will be base sum of blue penalties SUBTRACTED by the max value of at most k subarray sum

    calculating the prefix sum of the modified array (i'll call it $$$P$$$ and let $$$P[0] = 0$$$ (there should be $$$n+1$$$ elements in that array))

    keep only the start and end of continously non-descending subsequences of length greater than 1

    for example:

    $$$[0, 1, 3, 5, 7, 51, 9, 67, 3]$$$ would become $$$[0, 51, 9, 67]$$$

    let the size of $$$P$$$ be $$$m$$$

    let $$$D[j] = P[j]-P[j+1]*(-1)^{j}$$$ (this is also 0-indexed)

    for example: $$$[0, 51, 9, 67]$$$ would become $$$[-51, -42, -58]$$$

    the max subarray sum would be the same solution to the problem: pick at least $$$m-k$$$ non-adjacent elements in $$$D$$$ to maximize the sum

    since all of $$$D$$$ is negative -> pick $$$max(m-k, 0)$$$ non-adjacent elements in $$$D$$$ to maximize the sum

    this is a (somewhat) classic problem and has been solved here: https://mirror.codeforces.com/blog/entry/59818

    final time complexity is $$$O(nlogn)$$$

»
14 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I misread the problem C and thought the penalty is the sum of all values and it should be minimized. Anyways if this were the problem I can only think of DP which is $$$O(n*k)$$$ which will surely TLE and MLE both. Is there any better way to solve if the problem was this instead?

»
14 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

itsraajjjuuuu has solved b and c within fucking 10 minutes,and he took 42 minutes to solve question A.What a living legend.

  • »
    »
    14 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +3 Vote: I do not like it

    I registered for contest at 8:32 and I was reading problems before that when I saw first 3 problems were easy so I decided to do it ( My plan wasnt to participate today but I couldnt resist lol)

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Very fun C, thank you.

D felt a bit easy for a D. Solved it decently fast and then spent half an hour fixing issues with c++ modulo :D should have used python and i would of been top 500

Skipped E cause it just looked weird, still totally don't know what it's about

Managed to reduce F to a mathematical problem! I couldn't solve it but I think deepthink could (obviously did that for educational purposes after the contest). Fast hadamard transform... I didn't even know what that was :D oh well, can always study more

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My recent submission of Problem C has been classified as similar to other people which got me the strike. Please look at my solution 308130693 its the way i write binary search on answer. I literally got 0 idea how my submission got strike. You can go through my all last 200 problems and check if any of those is cheated or leaked code. I wrote the code all by myself. You can go through my leetcode and check there its the way i solve binary search i have start,end,ans and myfunc() i make cnt inside that...

[user:Neon][user:BledDest][user:adedalic][user:awoo] Please look at this matter because I am 100% sure this is some kind of misunderstanding I m ready to provide all the specific details you might need.

Please look at this and update me on your decision and I think you should give a check manually once

Thanks for looking waiting for the reply

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hey Everyone,

For C

10 1

BRBRBBRRBR

5 1 2 4 5 3 6 1 4 4

For the above testcase(changed slightly a[n-2] = 4 and k = 1 in this case), using the solution of the editorial it is giving minimum-max penalty as 4, but it is clearly visible that the minimum-maximum penalty would be 6 as the number of operations = 1 only. Can someone shed some light on this please