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

Hello Codeforces!

On Aug/17/2023 17:35 (Moscow time) Educational Codeforces Round 153 (Rated for Div. 2) will start.

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

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.

Good luck to all the participants!

Our friends at Harbour.Space also have a message for you:

Harbour.Space
WORK & STUDY OPPORTUNITY IN BARCELONA @HARBOUR.SPACE UNIVERSITY

Harbour.Space University has partnered with Giga (Unicef) to offer Master’s degree scholarships in the field of Computer Science and Front-end Development, as well as work experience.

We are looking for various junior to mid level candidates:

Front-end Developer:

This student will work closely with the blockchain developer and product lead to contribute to the design and implementation of user interfaces for the company's blockchain-based prototypes. They will be responsible for translating UI/UX design wireframes into functional and visually appealing web applications, ensuring seamless user experiences. The student will collaborate with blockchain and backend developers and designers to integrate front-end components with server-side logic and optimize application performance. They will also be involved in testing, debugging, and maintaining the front-end codebase. The intern will have the opportunity to gain practical experience in front-end development within the context of blockchain technology and contribute to the Giga’s mission of connecting schools to the internet.

  • Solid understanding of HTML, CSS, and JavaScript
  • Familiarity with front-end frameworks and tools such as React or Vue.js.
  • Strong problem-solving skills, attention to detail, and a passion for creating intuitive user interfaces are essential

Full Stack Developer:

  • Interest and experience in web application development, data products and OpenAPIs
  • Comfortable with on-cloud deployment services (preferably Azure), Git and CI/CD pipeline and deployment processes
  • Experience with open-source projects is highly preferred
  • Strong ML knowledge
  • Experience with data visualization tools like matplotlib, ggplot, d3.js, Tableau that help to visually encode data
  • Excellent communication skills, — it is incredibily important to describe findings to a technical and non-technical audience
  • Strong software engineering background
  • Hands-on experience with data science tools
  • Problem-solving aptitutde
  • Analytical mind and great business sense
  • Degree in computer science, engineering or relevant field is preferred

All successful applicants will be eligible for a 100% tuition fee scholarship (29.900 €/year) provided by the partner company.

CANDIDATE’S COMMITMENT

Study Commitment: 3 hours/day

You will complete 15 modules (each three weeks long) in one year. Daily class workload is 3 hours, plus homework to complete in your own time.

Work Commitment: 4+ hours/day

Immerse yourself in the professional world during your apprenticeship. You’ll learn from the best and get to apply your newly acquired knowledge in the field from day one.

REQUIREMENTS:

  • Industry experience
  • International exposure
  • Eager to learn
  • Sustainability is a key topic for you
  • You want to work for an NGO
Apply here →

UPD: Editorial is out

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

| Write comment?
»
16 months ago, # |
  Vote: I like it -11 Vote: I do not like it

Hope the round will be interesting

»
16 months ago, # |
Rev. 2   Vote: I like it -68 Vote: I do not like it

..

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

It will be very good, if educational rounds also have scoring distribution of problems!

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

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

Wow, hope a good round!

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

awoo uwu ><

»
16 months ago, # |
  Vote: I like it +5 Vote: I do not like it

Hope to reach pupil this round! Just 7 more points to go :O

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    Nevermind :(

    • »
      »
      »
      16 months ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      dw, next time you'll

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

      Just keep trying, and never lose hope. You should not stop believing that pupil is actually possible (which was my case when I had frequent rating drops). All the best!

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

      How did it go? I am also targeting for pupil but wasn't able to solve B. LOL

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

        I also couldn't, it's just terrible imo

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

          It’s so strange that the explanation for problem B is not very referential, and even you can’t solve it

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

            I mean, I couldn't solve it because of one case, I did write everything else, but still now I understand that Div 2B is harder than C sometimes

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

      CF-Predictor says you will get positive delta (+14), maybe you will reach Pupil.

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

        Maybe. Crossing my fingers right now, waiting for ratings to update

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

        Noooo! 1199. SO CLOSE yet so far!

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

      You will definitely reach your goal next time

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

        Thank you so much!

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

        Update: you were right! I reached pupil. Thanks for your support everyone!

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

Good luck, everyone! I hope there'll be good and pleasant problems at this contest

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

I LOVE EDU ROUNDS :3

PS: Earned +87 delta woooo!

»
16 months ago, # |
  Vote: I like it -12 Vote: I do not like it

I will drunk drive if I don't get positive rating in this round

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +17 Vote: I do not like it

    You can't drink and drive even if you get a negative rating, it's extremely dangerous.

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

    Everyone cares about ur life, please don't joke with ur own precious things. Drunk drive is very dangerous, right?

»
16 months ago, # |
  Vote: I like it +48 Vote: I do not like it

Imagine the C problem is another permutation problem:)

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

Hope to reach Pupil.

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

holp to reach specailist

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

Hope it will be an interesting round!

»
16 months ago, # |
  Vote: I like it -10 Vote: I do not like it

This round is so weird. Also A>>B and A>>C.

»
16 months ago, # |
Rev. 2   Vote: I like it +71 Vote: I do not like it

I will try to give constructive criticism this time.

Please, find testers or at least proof readers for your problem statements.

  • B is very hard to understand. What does an infinite number of stones mean? What is a1/ak

  • C is very weird. Alice makes the first move, but the first move isn't part of the game? How does that make sense?

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +15 Vote: I do not like it

    Too hard A also, i think a lot of people just resigned after trying A

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

      i almost gave up CP in general after not being able to solve A then i somehow figure it out, but i felt like A,B were harder than C.

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

        Nah, honestly A was the hardest of them all (ABC). Unless you knew the trick.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +21 Vote: I do not like it

    B felt more like a forced question.

    • »
      »
      »
      16 months ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      Most CP problems these days are forced. If you think about them, they are very unrealistic.

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

    Concubine approval

»
16 months ago, # |
  Vote: I like it +40 Vote: I do not like it

Cool C,D,E but terrible A,B imo.

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

    +1, but A was kinda funny

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

    Agree about B. I couldn't solve it and just left being sad, tried D but didn't like it after 5 minuter

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

The Pain is real T_T

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

how to solve C?

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

    It is easy to notice that the chip will be moving along the LIS ending at the i-th element. If the length of the LIS ending at the i-th element is 2, the i-th element is lucky, otherwise Bob can always make himself win. 219331114

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

      My solution is pretty much the same as dIsPoSEdOfFAcCC514's, but i managed to simplify the implementation a bit more IMO, turns out we just need to keep track of the minimums, that is the minimum of the whole array, and the minimum of the winning positions values. The next winning position's value will need to be between the minimum of the whole array and the minimum of the winning positions values. Also, CMIIW 219313622

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

    Let’s define cnt(pi) as count of elements lesser than pi that comes before it when going from left to right.

    Alice can choose an index i if all pj<pi for j<i cnt (pj)=0.

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

    Let $$$d_i = -1$$$ for all $$$i$$$. Now denote $$$d_i = 1$$$, if $$$i-th$$$ element is good, otherwise $$$d_i = 0$$$.

    We go from $$$0$$$ to $$$n - 1$$$. It's obvious, that if we now have $$$d_i = -1$$$, then it's gonna be $$$1$$$ if we have no $$$a_j$$$, such that $$$j < i$$$ and $$$a_j < a_i$$$ and $$$d_j = 1$$$, otherwise $$$0$$$. So we just keep $$$2$$$ minimum elements. One with $$$d_i = 0$$$ and one with $$$d_i = 1$$$ and compare $$$a_i$$$ with each of them. After this update minimums.

    Answer is $$$sum(d)$$$.

  • »
    »
    16 months ago, # ^ |
    Rev. 8   Vote: I like it +3 Vote: I do not like it

    I solved that in O(n) Time complexity (One scan to be exact) and O(1) Space Complexity (No need to make an array).

    So we declare two int variables as minLucky (the minimum lucky element until the ith element) and Min (the minimum element till ith element) and initialize them both as INT_MAX. Also, initialize a variable lucky = 0 (this stores the number of lucky elements).

    We run n iterations and in each one, input a number (say x) of the permutation and do the following: (1) if x is greater than minLucky, ignore and continue; (2) if x is smaller than Min, update Min = x; continue; (3) if x is greater than Min and smaller than minLucky, then x surely is a lucky element, so increment lucky and minLucky = x (of course x was less than minLucky to reach condition (3))

    Finally output lucky and there we go. You can find my code here.

    Note: I came up with this solution on my own, although after the contest ended. Also have NOT been able to mathematically prove the working yet. I just took many different test cases and made observations to reach this approach.

    PS: This is my first comment/post on this site. English is not my first language

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

I think making problems hard to understand is becoming a trend or something like that

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

    Imagine English being your official language but you find it difficult to even understand the problems T_T...

»
16 months ago, # |
  Vote: I like it +8 Vote: I do not like it

After being specialist for so many contests, I solved 0 and dropped to pupil, go next contest I guess

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

2 hours' time may be too tight to view all of the problems.

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

A was really hard. I feel that among A,B,C, C was the easiest of the three.

»
16 months ago, # |
  Vote: I like it +8 Vote: I do not like it

For D, I wonder what the upperbound for the minimum number of swaps needed is. It seems to be very low. I thought it was 2 or 3, but it seems I am wrong.

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

    Consider the case 111111111.....000000000.....

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

    Ah, I see now. Guess the constraints fooled me into thinking it was some kind of brute force.

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

    It does seem to be fairly low for this problem, but I think you can prove it's at least N/8 in the general case.

    Rationale: you can start with a string of (N/2) 0s followed by (N/2) 1s which creates an imbalance of (N/2)^2 and any swap can reduce the imbalance by at most 2N, and (N/2)^2/(2N) = N^2/8N = N/8.

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

    You can change any string s to any string t with at most n/2 swaps, so n/2

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

how to solve E

»
16 months ago, # |
Rev. 7   Vote: I like it 0 Vote: I do not like it

Problem C Can someone please explain how answer should be 1. n = 4 , a = 1 2 3 4

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

    Suppose you decide to take 2, then the opponent will take 1 and you won't be able to make a move so, you win. Suppose you decide to take 3, then the opponent will take 2, then you will take 1, because of which your opponent wins. Suppose you decide to take 4, then the opponent will take 2, then you will take 1, because of which your opponent wins.

»
16 months ago, # |
Rev. 3   Vote: I like it +4 Vote: I do not like it

Just to make sure my A doesn't fail, can someone verify this logic:

If string is "()" it is impossible.

If string is alternating for example: ")()()()" then you can use "(((...)))"

Otherwise you can use "()()()()()..."

Here is the code.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +7 Vote: I do not like it

    Yep, basically if $$$s$$$ doesn't occur in $$$(((...)))$$$ then it's an answer, otherwise if $$$s$$$ doesn't occur in $$$()()...()()$$$ then it's an answer, otherwise there is no answer.

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

      I was thinking along the same line but could not prove to myself why it works. Can you tell why this works in some mathematical proof ?

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

        Basically, we can prove by induction:

        Let see if $$$|s| = 3$$$:

        1. $$$((($$$ — $$$()()()$$$ is suffice.

        2. $$$(()$$$ — $$$()()()$$$ is suffice.

        3. $$$()($$$ — $$$((()))$$$ is suffice.

        4. $$$())$$$ — $$$()()()$$$ is suffice.

        5. $$$)(($$$ — $$$()()()$$$ is suffice.

        6. $$$)()$$$ — $$$((()))$$$ is suffice.

        7. $$$))($$$ — $$$()()()$$$ is suffice.

        8. $$$)))$$$ — $$$()()()$$$ is suffice.

        If $$$|s| > 3$$$ then it will have $$$1$$$ of those cases as substring, so it will be solvable with the same answer. Can't think of better way...

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

        if n=1 ---->impossible if n=2, ()--->impossible, )(---->(()) n >= 3: if in the string str, we found "((" or "))", then just construct ()()().., such string "((" is not substring of ()()()... otherwise, the string must be alternative, ()(.....or )()...., in this case, we construct ((((...))))

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

        You just have to cover all the cases. There are three partially-overlapping cases:

        1. S = () exactly.
        2. S contains )(.
        3. S contains (( or )) or both.

        We can easily prove that this covers all cases: if |S| = 2 then (), )(, (( and )) are exactly the four possible strings. If |S| ≥ 3 either S contains )( (case 2) or it is a sequence of ( followed by ) and since |S| ≥ 3 there must be at least two of one character in a row (case 3).

        In case 1 there is no solution, because any balanced bracket string must contain (). For case 2 (((...))) is a solution because it doesn't contain )(. For case 3 ()()()..() is a solution because it contains neither (( nor )).

  • »
    »
    16 months ago, # ^ |
      Vote: I like it -6 Vote: I do not like it

    i think you ignore the case when n=1 and string="("

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

      it's not a valid case

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

      minimum n is 2, so such case isn't possible. And even if this case was valid, the problem is impossible to solve because RBS has to contain both '(' and ')'

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

    In my solution I just make 2 strings "((...))", "()()..." and checked if input string is a substring of first, then the second is the solution. Also the "NO" answer comes only with "()".

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

Is it just me took a WHILE to clearly understand C...

»
16 months ago, # |
  Vote: I like it +19 Vote: I do not like it

B felt like as one of the most unfun kind of math problems

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

    It felt really forced, like they had to place a problem B somewhere and came up with a contrived problem

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

      During the contest I've got the general idea pretty quickly, something like:

      • Use as many of the non-fancy $$$k$$$ coins as possible
      • Fill the rest with as many of the fancy $$$k$$$ coins as possible, then use $$$1$$$-coins
      • In some cases we want to use 1 less fancy $$$k$$$ coin, then fill the sum with $$$1$$$-coins

      But translating that into actual expressions felt terrible, at least for me

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

Why all the problems is about to find all possible combinations of the answer and build the solution upon that, it felt like disguised combinatorics round.

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

    Video editorial for problems A&B:

    https://youtu.be/p-nKn3Hg9JE

    Thought would be useful!

    IN ENGLISH

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

      That's really nice! I appreciate people making video editorials in English (looking at you Mustafa), always much easier to understand. Hopefully it'll be useful to people who couldn't solve it!

»
16 months ago, # |
  Vote: I like it +9 Vote: I do not like it

How to solve D? I have only one observation: Lets call number of 01 — number of 10 "Balance" When I swap i, j such that a[i] = 1 and a[j] = 0 I add i — j to balance and j — i otherwise Please explain full solution to me

  • »
    »
    16 months ago, # ^ |
    Rev. 6   Vote: I like it -21 Vote: I do not like it

    UPD: My greedy solution was wrong

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

      WTF

      I did this and got Wa on test 5

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

      Can you prove that this greedy approach works? I mean, apart from the fact that it passes tests. I had similar idea but I couldn't think of a nice proof

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

        every swap you can decrease the diff between 01 and 10 by 2, and you can always increase that by adding an additional character to the left or right that changes the diff.

        So just pick pair i,j that max out that diff every time.

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

        In fact it doesn't work and it's hacked

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    I solved it using 3D-DP. Sketch: Assume w.l.o.g there are more 10 than 01. Then there is a diff > 0 you need to fix. Swapping a 1 with a 0 on the right fixes 2*(difference of indices). Now you can do similar to subset sum dp (you need a third dimension to store the position of the first 0 you used). The value of an entry denotes how many swaps you need to achieve this sum. Total runtime O(n^4).

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

      How much memory do you use?

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

        A little bit less than limit (237MB), but I could get it down by factor 8 quite easily (dp entry only needs 1 Byte + the diff can be upper bounded by (n/2)*(n/2)). You can also get rid of the first dimension completely just like in subset sum.

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

          And how do you deal with situation in which you need to swap some 1 with some 0 and then you swap it again with some other 0?

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

            I think this can't happen because then you could have just swapped it with the other 0 in the first place.

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

      Can you elaborate more on your DP-States?

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

        One invariant could be: $$$dp[i][j][k]$$$ is how many swaps you need for sum $$$j$$$ using only '$$$1$$$'s with indices between $$$i$$$ and $$$n$$$, assuming the smallest position of a '$$$0$$$' you have used for a swap is $$$k$$$.

        Go through from $$$i=n$$$ to $$$i=1$$$ and compute transitions.

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

          Thankyou

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

          Why would you want to store the smallest position of 0?

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

            You somehow need to ensure you don't swap two 1's to the same 0 position and this is a way to achieve it.

»
16 months ago, # |
Rev. 3   Vote: I like it +6 Vote: I do not like it

for D we can see that whenever a swap happens, the sum of 01 and 10 doesn't change. Also looking at 10000, we can see that we can just move the 01 and 10 2 unit closer to each other by swapping an additional 1 more character to the right.

tldr is the diff between 01 and 10 count must be even. Swaps 1 and 0 always move the diff between them by an even number. So just swapping the best 1 and 0 pairs until they are equal

Is this a greedy problem? Wondering why s <= 100.

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

this was WA2forces for me but the problems were good

»
16 months ago, # |
Rev. 2   Vote: I like it +29 Vote: I do not like it

Problem E is almost the same as this one. Check out 211055789 and 219307318.

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

Nice contest! Gain a lot.

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

Can we do E like this:

E
»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In Problem D what can be the maximum size of 0 or 1 individually as the string can always be made balanced

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

    Maximum size of 0 or 1 doesn't matter for solution.... But maximum value of balance matters which can be at most n/3*n/3

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

How to solve B?

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

    ternary search or some simple math

»
16 months ago, # |
Rev. 2   Vote: I like it -8 Vote: I do not like it

why dp solution dosent work for c , 219347506 thanks.

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

    I wish your code was readable.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +34 Vote: I do not like it

    bro your code looks like its from a nuclear reactor in Iran

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +17 Vote: I do not like it

    You are using memset on a 3e6 size dp for every test case. The total possible test cases are 1e4. So time complexity of your code will be more than 1e10.

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

    maybe because it's a segment tree problem ?

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

    bruh what do you need all those defines for, bet you don't use even a quarter of them often enough to justify adding them to the template

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

Couldn't solve C because I swapped a1 and ak while taking the input OR

cin >> m >> k >> ak >> a1;

Help me cry

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

so many case handling :((

˙◠˙˙◠˙˙◠˙

»
16 months ago, # |
  Vote: I like it +31 Vote: I do not like it
»
16 months ago, # |
  Vote: I like it -20 Vote: I do not like it

Problem B is one of the worst problem description

»
16 months ago, # |
  Vote: I like it -7 Vote: I do not like it

The worst tasks I've ever seen

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

Does, Problem B is based on Binary Search?

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

    I did it ternary Search

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

      you can't even do simple math?

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

        You don't need to be rude to make a point! What's wrong if someone solve it with ternary search instead of SIMPLE MATH!!!

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

    No I don't think so , there is no monotonocity of some property , It was just greedy one.

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

Actually a simple way of solving problem A is to check whether there exists a pair of adjacent brackets that are both left or right (like “((“ or “))”). If true, the answer should appear like “()()…()” If false, the answer should appear like “(((…()…)))” The only exception is string “()”, u just need to especially judge if the given string is exactly that thing. I personally consider C harder than A, because it took quite a long time for me to figure out how to solve LIS in O(nlogn) time…

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

    i don't think lis is needed though:

    My submission that passes tests 219294134.

    When i find a new m2, that element is winning because it can't reach any former m2 (all of those are bigger) and there's an m1 that the m2 can reach (meaning that a move exists and it leads to a losing state). It's easy to see that all the other moves are losing : if an element doesn't enter any of the ifs, it's trivially a losing one as that can reach another losing element (basically it can reach any m2, as it's bigger).

    This proof feels harder than the code, i 100% didn't think it this way when i wrote it but it feels right.

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

From the rules of some earlier rounds:

" 12-hour phase of open hacks after the end of the round (hacks do not give additional points)

after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated "

Will this thing (rejudge on successful hacks) be used here?

»
16 months ago, # |
Rev. 4   Vote: I like it -38 Vote: I do not like it

n^4 passing for D:

»
16 months ago, # |
  Vote: I like it +21 Vote: I do not like it

Hope codeforces catch all of them https://youtube.com/@codingSchool2.O

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

Hi, i am a beginner , tried the first question didn't got it then went to the second one , thought that i might be able to do it but then time passed and i wasn't able to do it. can someone give solution or tell where i can find proper solutions suitable for beginners.

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

    Hope that my solution is right and easy to understand 219268377

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

      That code is extremely clean. Amazing job man

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

    I would recommend you to firstly participate virtually in some Div3 or even Div4 rounds. Difficulty of problems there should suit you way better than Div2. But to be fair, usually problems A and B are a bit easier than in this contest. Good luck!

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

    DW, this contest was way harder and weirder than other div2 contests. Try again in another contest.

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

    A is the kind of stupid problem that you take a bold guess by intuition. I looked at it for 5 mins and guess I only have to test ()()() and ((())) kind of bracket sequence and luckily it passed. I did a little proof after this. And B is just simple strategy based on modulo. You can find editorial shortly after the contest where you read solutions.

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

      where can i see the editorial , on youtube or it is available on codeforces only?

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

        First check cf editorial, and then if you don't understand (cf editorials are not necessarily well-written), there is a comment section below the editorial. Still don't understand, go find other non-official explanation on the Internet (I use Chinese). Or you may find competitive programming communities somewhere to ask.

»
16 months ago, # |
  Vote: I like it +29 Vote: I do not like it

Nice massive hacks on D

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

    Can someone show simple test which fails on greedy solution?

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

      For example like this: 010000100000100010001011010010000110010011000101010001100100110111000101110111011110100110101

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

I HAVE OBSERVED THIS TREND IN RECENT CONTEST THAT LANG OF QUESTIONS ARE TOUGH TO UNDERSTAND. ITS MY HUMBLE REQUEST TO MAKE SINPLER STATEMENTS IF POSSSIBLE

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +26 Vote: I do not like it

    I do agree that it's frustrating to read long statements. Moreover, I also agree that long statements does not fit for contests where time is short. Especially, for platform like CF. However, your all caps comment made it hard to read. Hence, my conclusion is your comment is not much different from unnecessary long statements! LOL :v

»
16 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Can someone write a blog about this because more than 800 watched the videos https://youtube.com/@codingSchool2.O

  • »
    »
    16 months ago, # ^ |
    Rev. 3   Vote: I like it -13 Vote: I do not like it

    Deleted

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

      I don't think it's feasible for Mike or any other admin to track all the cheaters. Especially, folks who share codes outside the platform anonymously. At the end of the day, it's just an online contest. If you focus on learning and growing your problem solving skills it does not matter how many cheaters out there. Certainly, they will have some impact on the rating. But rating is just a number. If you can solve 2 problems in div 2 on average now, your concern should be how can you solve 3/4 regularly in the future. Cheaters will most likely stay at the same level because their main focus is not learning and growing skills IMO. That means at some point you will surpass them if you continue working on improving. And from that day onwards, they will not have much impact on your rating.

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

How to solve E? I already knew how to get the shortest path from a pair of character to another. But my solution seems to run in m*26^4 so it didnt pass :(

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +48 Vote: I do not like it

    Let MX denote 26*26. We can create (n-1+MX) nodes weighted directed graph. n-1 represents cursor position while 26*26 extra nodes represents all possible two length strings. For the ith position of cursor we have to add edges of weight 1 between each pair consecutive positions ,an outgoing edge from current position to string cursor is representing as weight 0 and incoming as weight 1. Now we can calculate distances to all other nodes from those MX nodes in O((n+MX)*MX) using 0-1 bfs. Now we can reach from p to q without going to any of those extra nodes in abs(p-q) steps or if we visit any extra node the answer from such a node can be computed as d[p]+d[q]-1.So each query is computed in O(MX). So final complexity stands O(MX*(n+q)) for my approach.

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

      Ah okay that makes sense, my solution was a bit different than yours. Thanks for the reply!

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

Around 1/3 of Problem D AC's hacked

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Were the hacked solns greedy?

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

      my greedy got hacked

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

      I have no idea but looking at the constraints I'd be surprised if a greedy solution was intended. Didn't even think about it because of this, so dunno.

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

      most likely yea, intended solution I think uses O(n^3) dp. I ended up doing some omega scuffed greedy that somehow passed pretests, but from looking at hacked solutions I already knew that something was off

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

Can someone explain the C problem solution, or just name the type of problem? Got the A and B, C was out of time for me.

UPD: Damn it was easy....

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

problem statement of B was difficult for me to understand

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

A simple solution for C

Key solution: A number is unlucky iff 0 or 2 jumps to left are possible from it.

https://mirror.codeforces.com/contest/1860/submission/219359755

»
16 months ago, # |
  Vote: I like it +2 Vote: I do not like it
»
16 months ago, # |
  Vote: I like it -8 Vote: I do not like it

do we get anything for hacks? Like less penalty?

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

Why so much down votes ?.At least they puts efforts to make contest for us.We don't pay anything.

»
16 months ago, # |
  Vote: I like it +5 Vote: I do not like it

Great contest, although I didn't address D. This idea of D transferring the contributions generated by the two 01s to the characters themselves is great!

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

How i can solve B with binary search?

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

Hello everybody, I made a submission for C a few minutes ago (after the contest). Even though it says Accepted, i have the feeling that it will FST. It's just over 15 lines (apart from the template).

Try hacking it.

Code

Submission: 219367730

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

    It is correct, because it's a convoluted version of the solution vinren explained above. Compare with his solution: 219313622.

    To see that it's the same, consider that whenever you do set.upper_bound(-x) == 0 you are effectively asking: is the minimum element in the set less than x? But to answer that question you do not need to maintain the complete set of values; it's sufficient to track just the minimum.

»
16 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Shall I get bonus points for a successful hacking on the 12 hour hacking phase?

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

    No, but you can hack those in front of you and get higher rating

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

Did somebody use this approach to solve problem B? I just come up with it now. The code is commented so you can understand whats going on

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

Thank you guys for the contest . it was a very good contest, i hope next contest will be the same

»
16 months ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

I find myself stuck in A B C general math problems. Due to this I am not able to give time to harder problems during the contest.

This thing happened with me in last contest's B as well as this contest's B. I find it difficult to understand some general math based solutions.

Can anybody give me suggestions for how to quickly come up with mathematical solutions. This really slows me during the contest. Even while practicing problems I have noticed this weakness.

I am quite ok with number theory problems. Difficulty arises when some general math and greedy are there.

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

    Try to come up with some obvious greedy ideas, then try to split this greedy in a small number of cases, and work with each one individually. Eventually you will become good at understanding formulas that you're writing

»
16 months ago, # |
  Vote: I like it +33 Vote: I do not like it

I didn't participate in the contest. But why so many downvotes eh? I think problems were good. I love A,C,D, and E. Although I find B is a bit too "mathy" but I don't think this contest deserves that much downvote tho

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

    Maybe due to the weak tests for D. I like the problems themselves too.

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

      I guess pretests for D were weak so that "hacking phase" served its intended use.

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

        There are no so-called "pretests" in CF mode. I can understand weak pretests in CF mode (actually most users don't). However if the tests in exICPC mode are weak, the wrong solutions will pass as long as there are no users are hacking.(for example, when some significant events take place and high-leveled users are not online)

        Anyway, optimistically, this gives a lesson to user who do not prove and check their solutions. This will influence a lot of people in future CF mode contest!

»
16 months ago, # |
  Vote: I like it +2 Vote: I do not like it

It hurts so much to get hacked for the first time, maybe many wrote to the greedy in D and will be able to understand me.

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

Why not system test (i’m new here pls no downvote)

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

    Educational contests are different from the normal contests.

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

    In Educational rounds and Div-3,4 contests, system testing takes place few hours after the hacking phase finishes. Also, system testing will include the successful test cases generated by hackers.

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

Problem C is so interesting that I spent almost one hour on it.

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

Can anyone tell where can we find the editorial to this contest?

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

Hi, awoo, do you play genshin or starrail, which leads you to provide these weak pretests?

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    Tests is good, you got fst because you got skill issue.

    P/s: We don't have pretest here. You get WA on hacks (because of your skill issue.)

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

Problem E is actually similar to this.

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

Good round, but problem B...

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

Hackforces round.

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

I am currently a newbie and the details above says that the contest is rated for those with rating below 2100 so why is the contest listed as unrated on my profile? Someone mind explaining?

»
16 months ago, # |
  Vote: I like it +44 Vote: I do not like it

the problems were good. thanks for the contest adedalic BledDest awoo ! ignore the downvotes

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

    Learn to be honest.

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

      learn that you dislike problems because you are unable to solve them (due to skill issue)

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

        Learn that you only liked the round because you solved the 3 easiest problems and got +ve.

        • »
          »
          »
          »
          »
          16 months ago, # ^ |
          Rev. 2   Vote: I like it -7 Vote: I do not like it

          "learn that you dislike problems because you are unable to solve them (due to skill issue)"

          Didnt comment on this? does that mean it is true LOL

          Besides, the complains in this contest were mostly regarding B and C, and if you say that they are "easiest", then you shouldn't be crying about the contest being bad, you should focus on quality of D-which you cant cuz skill issue again

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

why this round is showing unrated even if i am in Div 2 ??

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

    Wait for some time, the rating will update in 2-3 hours. It always shows up as unrated shortly after the system tests.

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

Can anyone please explain this elegant solution (219271388) of D by jiangly?

  • »
    »
    16 months ago, # ^ |
    Rev. 3   Vote: I like it +18 Vote: I do not like it

    wow, that's a fantastic solution.

    I guess the idea is: let c00 be the count of 00 pair, so does c01, c10, c11. Given c01 = c10, we have

    1. c00 + c01 + c10 + c11 = n(n-1)/2 (all pairs)
    2. c01 + c11 = c10 + c11, which is also the number of pairs end with 1 and begin with 1.

    let c0 be the number of 0s, c1 be the number of 1s. we know the sum of the total number of pairs begin with 1 and end with 1 is c01 + c10 + c11 + c11, so for each it is ( c01 + c10 + c11 + c11) / 2,which is param "need"

    then uses a dp[i][j][k] to find the min ops to achieve need, where i means consider first i items, j means the total 1 been used, the k means the (c01+c11) till now. And the value is how many position we put 1 but it is 0 original.

    The answer is dp[n][c1][need], because each swap we can put a 1 in its final position

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

I want to report @erfge56gyt4w5h356 for obfuscating his solution of E.

https://mirror.codeforces.com/contest/1860/submission/219309571

I though this wasn't allowed by the contest rules.

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

I didn't solve a single task — I was unsuccessfully struggling with task B the whole round, — but still got +125 points ¯\_(ツ)_/¯. Is there any article on how rating on Codeforces is calculated?

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

    Maybe this will help link

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

    I'll try to explain it without going into the math behind it. In the first 6 rounds combined you get a bonus rating of 1400, split as 500-350-250-150-100-50 and your assumed rating for your first round starts at 1400.

    Your rating change according to your performance will be calculated as bonus + (whatever you get because of your assumed rank vs gotten rank)

    So basically you had a 250 bonus already as it was your third round and whatever you got was a score that stacked onto that

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

where is the editorial?

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

    Authors of Edu. rounds like to post editorial in a few days after the contest, they do this so that the participants can discuss their solutions without authors ideas.

    At least that's what I remember from some comment from awoo or bleddest

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

I misread problem C, it was interesting though. Also, B was like too many if else statements!

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

It was the best codeforces round (in my opinion), thanks to BledDest, Neon, adedalic and awoo!

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

About my solution to Problem C 219315276 was judged to be duplicate, I used the source code that had been published in 2017, its content is linked at: https://blog.csdn.net/George__Yu/article/details/75896330 Your text to link here... I don't think that constitutes cheating