Codeforces и Polygon могут быть недоступны в период с 6 декабря, 22:00 (МСК) по 7 декабря, 00:00 (МСК) в связи с проведением технических работ. ×

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

Автор shiny_shine, история, 33 часа назад, По-английски

Well, codeforcers, it's quite a while since I visited here last time.

If you read this blog, you might know that, a few days ago, NOIP 2024 took place. On Luogu, the difficulties of the four problems are defined as Blue, Green, Purple and Purple. However, when I saw that problem A is blue, I became confused and couldn't understand why it's blue. The forum of this problem in Luogu is CHAOTIC. What I mean is, there are people consider this problem as a problem even a newbie (yes, codeforces newbie) can solve without difficulty, while others say this problem has a difficulty similar to problems in Provincial Team Selection. I'd like to ask you, how difficult is this problem? Here comes the statement:

An integer $$$n$$$ ($$$1\le n\le 10^5$$$) and four 01-strings with a length of $$$n$$$ are given, I will call them $$$a,b,c,d$$$ below.

Now, you want to let string $$$a$$$ and $$$b$$$ be as similar as possible. So, you can perform the following operations:

  • Operation $$$1$$$: choose an integer $$$i$$$ ($$$1\le i< n$$$), which satisfies $$$c_i=c_{i+1}=1$$$, then swap $$$a_i$$$ and $$$a_{i+1}$$$.
  • Operation $$$2$$$: choose an integer $$$i$$$ ($$$1\le i< n$$$), which satisfies $$$d_i=d_{i+1}=1$$$, then swap $$$b_i$$$ and $$$b_{i+1}$$$.

After performing the operations above for arbitrary times, possibly $$$0$$$ times, print the following value:

$$$ \max \sum_{i=1}^n [a_i=b_i] $$$

And here's my code which is able to pass all the samples Luogu given:

Code

Please write how difficult do you think of this problem in comment, and a Codeforces difficulty value if you can. Thanks!

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

»
33 часа назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

2100 i guess

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

Not sure about solution so I'd just speculate. Can this problem be solved greedily?

We can choose either $$$a$$$ or $$$b$$$ WLOG and fill it greedily from left to right in accordance with the supply of the current connected component in the non-chosen string. Like, for each string, a consecutive series of $$$1$$$ on its identity string ($$$c$$$ for $$$a$$$, $$$d$$$ for $$$b$$$) is a component, and every $$$0$$$ is a separate component.

If this solution was the case, I think the Codeforces rating would fall around 1600-1700. But proving and/or intuitively discovering this is odd on its own.

»
33 часа назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

Div1 A maybe? Hard to estimate exactly since I don't know the Div2 difficulties nowadays, but I think it's pretty easy to see the greedy approach and why it works. I'd expect to AC it in ~10 minutes if it's given as Div1 A which sounds about par.

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

It's a greedy I figured out in 15 mins give or take. Somewhat annoying implementation. I would say between 1400 and 1700? I feel like I have seen either a div2 B or a C with annoying 0s and 1s counting.

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

Just made a Luogu account for this problem. I would say this is pretty easy problem like the first idea that came to my mind of just doing it greedily worked, It could have been hard to implement but I just abused DSU and did it pretty fast, I am pretty sure if you take away the implementation a newbie could very well come up with the idea, but I would rate it 1400-1700.

Here is my Code
»
26 часов назад, # |
Rev. 2   Проголосовать: нравится +28 Проголосовать: не нравится

I think this is 1800

At first, I thought this problem is trivial, as you just go through and perform an arbitary match if you can. I thought it is an easy (guarnateed profit)>=(maximum cost) situation. I thought it was 1300 upto here.

Then, I realised this is wrong. There are situations where both 0 and 1 could be matched. And you could not decide it without serious lookaheads. This can happen when the number of remaining allowed matches is less than the potential matchings you could do. This would reject the simple greedy more than enough for my taste.

Turns out, it is still possible to solve from here: We just take keep the potential option if both can be matched. That is, after each matching, we can have "stuff that must be 0", "stuff that must be 1", "stuff that can be either 0 or 1 as you like".

If this were the only solution then it would be 1900. I would never have looked any further and just implement it out. However, seeing the simplest greedy is actually extremely subtle. It depends critically on the fact that a group of size $$$k$$$ would have $$$k$$$ opportunties to match with something else before. Making such number of matches must result in either (1) '0' or '1' being exhuasted, or (2) the numbers of '0's and '1's are at most the remaining number of matches you are allowed to perform. In both cases, all the matching can be conducted without any potential nontrivial choices.

If I am forced to discover this, I would even rate this as 2700 or higher.

My conclusion is: Most people that submitted this greedy either did not prove, or gave a wrong proof. There are some more involved, but certainly correct solutions, and many should have chosen them instead.

That said, guessing a greedy that then it passing is still a skill, so I think a 1800 rating is appropriate: however, it is far more volatile than what this rating suggests.