Hello Codeforces!

We invite you to Codeforces Round 821 (Div. 2) starting on 19.09.2022 17:35 (Московское время). The round is **rated for users whose rating is lower than 2100**.

All problems were mainly created and prepared by me. One problem is revised by mejiamejia. I would also like to thank:

- MikeMirzayanov for Codeforces and Polygon platforms,
- KAN for helping preparation of the round,
- Arpa for coordinating and reviewing the round,
- mejiamejia for developing one problem and a lot of advices,
- satyam343, 74TrAkToR, MagentaCobra, valeriu, Andreasyan, darkkcyan, Vladithur, Etherite, welleyth, mjhmjh1104, emorgan5289, jeroenodb, oolimry, willy108, uuzlovetree, abc864197532, tibinyte, -skyline-, TomiokapEace, gyh20, SSerxhs, djq_cpp, Lucina, ugly2333, ITO, ak2006 for testing the problems and giving feedback, especially Vladithur for trimming the statement,
- All users for participating in the contest!

You will be given **5 problems** with one subtask and **2 hours** to solve them. The score distribution will be announced closer to the start of the round.

Good luck, and have fun!

**UPD1**: Score distribution is **500** — **1000** — **1500** — ( **1500** + **750** ) — **2750**.

**UPD2**: System testing has been finished. Congratulations to the winners!

Out of competition

Official participants

- LikeStrangers
- i_will_be_less_than_blue
- tlvvpdus
- PokerCareer
- casual11
- wildwolf_ptyzs
- Puranya_
- 963noah
- LovelyEther
- warner1129

**UPD3**: Editorial is published.

How is this post 2 years old lol

If you create a blog post and save it as a draft, when you publish it, it is labeled with the creation time instead of the publish time for some reason. But it still takes a huge amount of foresight to create a blog post for a contest 2 years in the future...

I think contest stock has been elapsed for that reason they took long back created set of problems or like that!!!

Does it mean, I have to wait approximately half year more for my contest?)

2 years ago◔_◔It might have been a clone of this announcement before it got edited and published, since it is also a contest prepared by the same author two years ago.

That's not how that works. Check SecondThread's comment above

2 years ago!!

LOL!

Imagine getting a necroposting warning for commenting on a future contest

"This post was published a long time ago. Please refrain from commenting unless you have a really reasonable cause to leave a comment. Necroposting is discouraged by the community." The reasonable cause is that the contest is starting in 4h :)

This must be a long-term project of creating a VERY VERY HIGH-CLASS Contest.

Imagine waiting 2 years for a score distribution

LoL,

Imagine preparing a blog and waiting 2 years on round queue to publish the blog

I am coming back every hour to see if any rated contest has been scheduled or not, suddenly there is contest rated 2 years ago! LOL no literally LOL!

Hello, please put more contests on weekends thanks

This would be great.

I agree

Lol

.

!!!!

Writes blog. . .Gets publishedLOL

wow, what a scheduled site :) They have prepared times of contests since more than tow years ago!

Is it just me who keeps coming back every hour to see if any rated contest has been scheduled ?

wow 2 years ago

Finally getting a canon episode after 2 years of fillers :)

King Arpa orz

2 years ago ? amazing!!!

This is what called " time travel to 2020 " .

2 years ago ? it is ez to flash to see a scoring distribution >

When you use internet explorer to make a contest:

i like how just 2 of the testers are actually in div2

More of them were probably Div2 when they tested but their rankings have gone up in 2 years..

I feel the same way, maybe I should invite some testers with lower ratings.

but the difficulty balance/overall was amazing for div2 round nonetheless, thanks!

Hmm! 2 years ago! It's a long queue then

Two years old announcement!! OMG

Eager to participate in a contest which was ideated before I even started Competitive Programming!

https://en.wikipedia.org/wiki/Main_Page

Lmao, Rotavirus day!!!

Was this contest planned 2 years ago? :P

Blog owner waitingI wonder if this round will be more difficult

I also wanna write a contest announcement and save it as draft now and will publish 4 years later ,,btw you are making all of us necropost

The round drafted to years ago! Wow!

Blog should also contain:

Thanks to tlsdydaud1 for coming up with the idea to use the drafted blog.

Really a nice idea, I think almost 50+comments will be just on this (at the end of contest).

It's amazing... Still i cannot believe this...it was created 2years ago

Imagine creating a blog in corona period and posting it two years later when it's finally over...

2 years ago I have only 0 ratings lol

I created a blog too in case i become master and prepare a contest :)

OP’s first contest was held on 8/21 two years ago This blog was created two years ago and the Round is 821

I didn't notice that until I see this comment

Time to upsolve everything from 2 years ago...

I think pset might beharderthan as usual div.2:(What made you come to this conclusion?

hahaha

In the spirit of tlsdydaud1, I too have created a draft for a future round:

https://codeforces.com/blog/entry/107056

See you all in 2 years for Round #999

2 years ago lol?

when will there be a weekend round T_T

this contest will harder for me

I hope this everyone can achieve good results, and I hope I can also break through

Jokes aside, I can think of two plausible explanations for the 2-year-old timestamp:

It really did take that long to actually finalize the contest, possibly because people got busy or unavailable, or there was a lot of back-and-forth about the problems, etc. Observe that tlsdydaud1 was not involved in problemsetting since August 2021, so they may have been preparing this contest across two years.

tlsdydaud1 started writing a blog entry two years ago (which may have been completely unrelated to any contest announcement) and then abandoned it for some reason. Two years pass, and they now decided to host a contest, realized that they had a draft from back then, and figured it would be amusing to edit that ancient draft to reflect this new contest, in order to see how people would react to the apparent age of the posting.

2 years later wow

wow 2 years agoI hope I'm the Candidate Master this time. Come on！

Though I don't participate because the next day is one of my most important event at my school...

But two years for participating, waiting, and then publishing.

I have a huge respect for all the people who built this contest!

Hope everyone luck!

They are preparing for this from 2 years, even tourist will have to think if he participates.

" i think, this contest was made for me only. "When will the score distribution be announced?

We will update soon.

Codeforces Language Picker -- chrome extension to fix codeforces language picker.

The score distribution will be announced closer to the start of the round.So, we have to wait 2 years for score distribution.

where is score of problems ?

the contest will start!

I hope I reach Expert today

Good_Luck Brother

and you did :)

What about "The score distribution will be announced closer to the start of the round."??

tru

tlsdydaud1 may be author forgot to update score distribution. It's 3 minutes left to start contest.

okay but whats the point of hiding scoreboard?

2 years ago^_^

How many problems can you solve/submit in one minute in a contest ?

tourist : yes

(tourist orz)

Nice to see that this contest is created 2 years ago..

It's a nice contest , because I think each promblem is of the almost right difficulty .

How to solve D2?

Yes, i also wanna know. I think it is some dp that i'm just too stupid for. My greedy doesn't worked out

dp solution idea:

create array pos of indexes of points we need to change

it's easy to see that we only want to change the neighbors in our array using the x operation several times

dp from left to right, 2 values — cost if used X for points i and i — 1 and if not used. Points modified with x add (pos[i] — pos[i — 1]) * x, other add y / 2 for each

Nice solution, thanks for helping out

Was this contest relatively easy compared to other div2 contests or I just had a lucky day?

I think it's easier. but obviously, the problems were interesting with perfect difficulty.

Well-balanced contest, thanks for authoring it, loved problems <3

After one day's work, I am too dumb to code...

how to do C?i could not think of any idea.

let the first element of array has parity p . now check for the last element whose parity is p (let its position be j) .now for all 'i' from 1 to j-1 elements whose parity of element is p, apply one operation on i and j since both has same parity arr[i]+arr[j] will definitely be even i.e a[i]=a[j]

now for all i from 2 to n whose parity is not equal to p apply one operation on 1 and i since arr[1] and arr[i] are of different parity their sum will be odd i.e arr[i]=arr[1]

after this every element in array becomes equal.

How to solve C?

I can describe my algo:

(if it is even)

Find last occurrence of even element

Now go through the whole array from left to right and if we meet even number do (i, lastEvenInd) to make them equal. If we meet odd number do (1, i) to make it equal to the first element

Pretty the same if first one is odd, but all "odd" replaced with "even" and vice versa

Just do $$$l=1, r=n$$$ as first operation, then you can make all other elements equal to the border ones. Saves you the analysis by cases.

Yep, you're right. Thanks for advise

Ohh understood, i was bit close to that logic but not able to solve. Thx

Make a[1] and a[n] equal. For i = 2 to n — 1, if a[i] + a[1] is odd, then the operation is (1,i), otherwise (i,n). After this we can achieve an array with the same number using n — 1 operations.

nice contest but isn't problem A a little hard for a?

The contest is quite tough for me :((((

Solved A, B in contest for the first time, yey!!

congrats!!!

Can anyone please tell me where I am getting wrong? My submission is : 172733662

have you checked the output for different scenarios for the gcd calculator function?

Thanks I got it now.

Very nice problems!I have really enjoyed C!Congratulations to authors!

How to do that C?

If first value is even, change all evens to last even, then change all odds to the first even (which is now equal to the last even).

Similarly, if first value is odd, change all odds to last odd, then change all evens to the first odd (which is now equal to the last odd).

In both cases, all values become equal.

Thx. By the way what would be the problem rating of question C?

I don't think that much casework is required.

Just Make first and last value to be same -> Operation 1 N

Then for all elements k in range 2....N-1,

If parity of element is equal to first element, apply k N

else apply 1 k

Can i get your C submission ? . i can solve D but C is not ,

https://codeforces.com/contest/1733/submission/172740905

E is the most ingenious task I have ever seen.

https://codeforces.com/contest/1733/submission/172736981 can somebody help me to find a stress test for my solution for c

test case:

Spoileryour answer :

Spoiler5 > 4

Here is an answer:

SpoilerIs there any chance of FST today? :3

In D1, what would be answer for the following test case

Test case6 right?

in D1,5 <= n <= 3000

n will be greater than 4

min array length is 5

You guys just saved me from a heart attack, thanks god

Not valid, since $$$n \geq 5$$$. I was worried about this case too, but they always made sure it's possible to deal with a consecutive mismatch through two $$$y$$$-swaps.

It's an invalid test case.

N>=5, Mentioned in the constraints.

Thanks for pointing that out! I totally missed this case. (So if not for the restriction on $$$N$$$ I would have failed probably pretest but for sure system test. Note: Always think about small cases! The only special case I thought about was with $$$N=2$$$, which would have needed a seperate consideration too.)

I feel like D2 should not have been worth only half of D1, since the additional work required for D2 that isn't covered by D1 is significantly tougher than D1 by itself, in my opinion. Like, I understand the argument that D2 by itself is worth 2250, but I think the distribution should've favored D2 more, to something like (1000 + 1250) instead, which would also suggest that D1 is easier than C (which, imo, is the case, if only because it's easy to get confused in C by the two scenarios, whereas D1 is very straightforward).

how to solve B and C?

In B, there will always be at least 1 player with 0 win and at least 1 player with 1 win. So exactly one of x and y will have to be 0 and other one will have to be a divisor of n — 1, since there are n — 1 games. Figure out the rest.

I was able to figure out almost everything in the problem but still the test cases were not passing , i submitted the code like 10 diff times.

B: One of $$$x$$$ or $$$y$$$ must be 0, because the loser of the first round wins 0. WLOG let $$$x$$$ be the non-zero value. Then everyone who won at least once would win exactly $$$x$$$ times, so $$$n - 1$$$ must be divisible by $$$x$$$. Now it's easy to make somebody win $$$x$$$ times and then let the next challenger be the winner for $$$x$$$ rounds and so on (it's simpler if 2 wins at first, so the winners are all gonna have IDs of the form $$$2 + ix$$$).

C: If the first value is even, then apply the operation on each even with the last even, to make all evens equal to the last even. Then apply the operation on each odd with the very first value (even) to make all odds equal to the first even (which is now equal to all other evens). Similarly, if the first value is odd, then apply the operation on each odd with the last odd, to make all odds equal to last odd. Then apply the operation on each even with the very first value (odd) to make all evens equal to the first odd (which is now equal to all other odds).

A great contest and 200+ rating increment :) Problem D2 is really nice Thanks !

You changed the constraints of D2 after the contest started and didn't even bother to make an announcement? I opened the “complete problemset” at the beginning of the contest. Got so many runtime error because of this. This is pathetic.

Sorry for that. The constraint changed just before the contest start, and it seems to have taken some time to reflect on the problem page.

imo, today contest is a lot of casework. It's not very interesting.

Problem E is similar to JOI 2009 Finals Problem 4. Also Problem D2 can be solved in $$$O(n)$$$ time

Can you explain your O(N) approach?

What's a non-O(n) approach? I couldn't think of one except an O(n) algorithm.

I used a simple DP whose size is equal to the number of mismatched positions. $$$dp[i]$$$ is the optimal way to pair up the first $$$i$$$ mismatches, except if $$$i$$$ is odd, in which case, one element is left unpaired. The array $$$mis[]$$$ stores the mismatched indices.

For even $$$i$$$ (nothing should be unpaired),

$$$dp[i] = \min (dp[i - 2] + (mis[i] - mis[i - 1])x, dp[i - 1] + y)$$$

For odd $$$i$$$ (one element unpaired),

$$$dp[i] = \min (dp[i - 2] + (mis[i] - mis[i - 1])x, dp[i - 1])$$$

This can be made even simpler by not separating into an even and odd case and changing the recurrence to $$$dp[i] = min(dp[i - 2] + (mis[i] - mis[i - 1])x, dp[i - 1] + y/2)$$$ and setting $$$dp[1] = y/2$$$.

Hello. For even

i, in the second part of theminfunction, how can you assume that the unpaired index indp[i-1]is noti-1? Because if it isi-1, you cannot pair it withiwithycost. Thanks.I only use the DP for the case of $$$x < y$$$ (D1 has a trivial algorithm that can be copied for $$$x \geq y$$$ in D2). If $$$dp[i - 1]$$$ has the last element as unpaired, then the minimum of the two considered values will always be $$$dp[i - 2] + (mis[i] - mis[i - 1])x$$$. Therefore, the $$$dp$$$ array will never store a value that corresponds to spending $$$y$$$ cost for an adjacent pair.

The cost of the operation is

`x`

, if`mis[i-1] + 1 == mis[i]`

. Can you please explain, why you are multiplying`x`

with the position difference. Why`(mis[i] - mis[i-1]) * x`

? ThanksLet's say there is a mismatch at index $$$p$$$ and the next mismatch is at index $$$q$$$. One way to flip both of these is to apply the operation on $$$(p, p + 1)$$$, then on $$$(p + 1, p + 2)$$$, then $$$(p + 2, p + 3), \ldots, (q - 2, q - 1), (q - 1, q)$$$. This will flip index $$$p$$$ and $$$q$$$ as desired, while indices in between (if any) will flip twice and will therefore be unchanged. There are $$$q - p$$$ operations being performed here, each with a cost of $$$x$$$, so the total cost of this approach is $$$(q - p)x$$$.

It is easy to observe that if any $$$x$$$-operation is to be performed at all, an optimal solution would apply it to some mismatched index chained to the next mismatched index as described above. Therefore, the DP only considers whether the latest mismatched index should be restored through an $$$x$$$-operation chain from the previous mismatched index or not, choosing the minimum of the two options.

anyone else totally misread A without the second mod k? just me being uniquely bad at reading problem statements... again? oh.

My misreading was more severe. I thought the operation was a[i] = a[i] % k, a[j] = a[j] % k and then swap a[i], a[j]. I have no idea how I could read like that.

Same.

same

misread C and didnt note m had to be less than n and wasted 30 mins coming up with a soln then realized after seeing pretest 1 fail and got correct soln 10 mins after contest ;)

i should really get better at reading in contest nerves

Same thing happened with me today :)

Solved 3 and one partial problem on Div.2 for the first time. Maybe the problems were a bit easier than usual Div.2.

I don't think they were easier, you just did a great job

Thank you.

D is not supposed to be solved by 4k people. This contest was a speedforces.

◉_◉

is D2 just D1 with x >= y, and if x < y then we:

get all the indices with different value of a[i] and b[i] clearly we can only make flip the bit pairwise. So the number of differences must be even. lets go from right most index to left most, If the gap (i — j) is D, then cost is D*x, but cost is capped at y. It's clear that it's always best to greedy starting from the right most index.

Just greedy imo solved in O(n) time. Idk what's the n^2 solution is given the max input is only 5k

then why did my approach — 172725963 — get a WA2? what cases did I miss?

I think that this does not work in this case:

Test8 2 7

10011001

00000000

It is better to take indexes 4 and 5 with x and 1 and 8 with y instead of using x twice

2 + 7 < 6 + 6

This is not correct. It is not necessary that you always match consecutive ones. Consider all non-matching indices to be $$$[1,3,4,7]$$$. You might match 4 with 7 and 1 with 3(cost = $$$min(y,3x) + min(y,2x)$$$). But matching 1 with 7 and 3 with 4 could be better($$$min(y,6x) + x$$$). This may happen when $$$y = 2x$$$ for example.

This is incorrect. Imagine that the indices where a and b are different are 1, 3, 4, 7, x = 1 and y = 2. Your solution would match 4, 7 and 1, 3 for a total cost of 4. But the optimal cost is 3, from matching 3, 4 and 1, 7.

That should not work. Do you have a submission to try and hack?

`X_XX_X`

with $$$y=3$$$ and $$$x=2$$$ should hack it.EditFunny, 6 people posted the same counterexample nearly at the same time. :)

Consider case:

12 1 6

100001100001

000000000000

According to you greey algo,the strategy is:

-change the 7-th and 12-th bit costing 5;

-change the 1-th and 6-th bit costing 5.

The total cost is 5+5=10.

But the optimal strategy is:

-change the 1-th and 12-th bit costing 6;

-change the 7-th and 6-th bit costing 1;

The total cost is 6+1=7.

Maybe I misunderstand you method,can you explain it?

Greedy doesn't work. Consider the following test-case:

A greedy approach would pair the first two 1s with a cost of 4, and the last two 1s with a cost of 4 as well, for a total cost of 8. However, the optimal choice would be to pair the middle two 1s for a cost of 2, and then the first 1 with the last 1 with a cost of 5, for a total cost of 7.

If your submission was truly accepted, then it could not have followed the greedy approach that you just described (unless the pretests were really bad, but I doubt that's the case, considering how many penalties I observed in D2).

Ok this doesn't work then. I guess it'd have to be DP.

Can anyone help me finding the cause of getting runtime error in problem C?

This is my submission of C

UPD:

GNU C++20 (64) giving AC but

GNU C++17 and GNU C++14 giving RE. Don't know why!!

AC Submission

RE submission

Can anyone explain?

The link is not working!!

I used GNU C++17 (64) and got Accepted.

But why?!!!!

You have a problem in this line :

`ll mn=a[od[od.size()-1]],pos=od[od.size()-1];`

Take this test case for example :Here (od.size() == 0) so od[od.size() — 1] ==> is like od[-1], which is a problem in cpp, I'm not shure but I think it's a buffer overflow.

Look, there is condition

if(a[1]%2) then do the odd part first else do the even part first.

so there will be at least one element in the container. so its not the problem.

in your case. even part will execute first.

sorry, you are right. actually it's this line :

`ll mn=a[ev[ev.size()-1]],pos=ev[ev.size()-1];`

for this test case :

in this case (ev[ev.size() — 1] ==> 1000) so a[1000] will be out of boundary.

ev[ev.size()-1)==>1 not 1000.

ev.size() == 1

ev.size() — 1 == 0

ev[ev.size() — 1] ==> ev[0]

ev[0] == 1000

remember 1000 is even so ev == {1000}

a[ev[0]] ==> a[1000]

Hey brotherman, In ev I'm storing the position of evens not the value. :3

Ok, here is your code giving AC in GNU C++17 : 172837822

Changes :

`for(ll i=od.size()-2;i>=0;i--)`

==>`for(ll i=(ll)od.size()-2;i>=0;i--)`

`for(ll i=ev.size()-1;i>=0;i--)`

==>`for(ll i=(ll)ev.size()-1;i>=0;i--)`

`for(ll i=ev.size()-2;i>=0;i--)`

==>`for(ll i=(ll)ev.size()-2;i>=0;i--)`

`for(ll i=od.size()-1;i>=0;i--)`

==>`for(ll i=(ll)od.size()-1;i>=0;i--)`

od.size() is unsigned, and when you tried to subtract a bigger value it caused a problem, you can search more about that.

great! thanks btw.

you're welcome.

such a great contest! orz tlsdydaud1

for the second case of B,why can't make each player won x times to achieve it? just like print:2 3 4 5 6 7 8 instead of -1? qwq

cause plyer1 won 0 times then

I have managed to pass D2 using a naive $$$n^3$$$ dp but checking only limited transitions. Feel free to hack this.

https://codeforces.com/contest/1733/submission/172714403

can you explain your dp?

Can someone explain the recursive formula for D2?

Can anyone explain D1 in a simple way please? Thank you...

Count how many indices have mismatches. Each operation flips exactly two bits. If the number of mismatches is odd, then it's impossible to fix all the mismatches, so the answer is -1. Otherwise, there are two cases:

The exceptional case to watch out for is when there are exactly two mismatches AND they are on adjacent bit positions. In this case, you can pair them directly for a cost of $$$x$$$, or you can pair each of them with some other distant bit position for a cost of $$$2y$$$ (note that this distant bit position flips twice, so it reverts to its original value). In this case, we output whichever of $$$x$$$ or $$$2y$$$ is smaller.

In all other cases, it's always possible to resolve the mismatches using $$$y$$$ operations. If we have only two mismatches, then they're not next to each other (since that's covered by Case 1), so you can just use a $$$y$$$ operation. If there are more than two mismatches, you can divide the number of mismatches by 2, and pair indices from the first half with indices from the second half, so the paired indices are never adjacent and the cost is always $$$y$$$. Here, the answer is just (number of mismatches)/2 * y. This is always optimal because $$$x \geq y$$$.

Thank you,it's become clearer.

First you must notice that if the parity of ones/zeros on string $$$a$$$ and string $$$b$$$ don't match. Then, it's impossible.

Now, with the impossible case done, you can see that if for some index, the character in string $$$a$$$ isn't equal to the character at the same index in string $$$b$$$. Then, as the parity of ones and zeros of both string are equal, there must be

evennumber of indices such that the characters don't match. You can try to prove this.So, finally, there is one last thing you have to see is that after being sure that the first two observations are indeed true.. If $$$k$$$ is the number of indices and positions are $$$p_{1}, p_{2}, \ldots, p_{k}$$$. Then, if $$$k \ge 4$$$, even if $$$p_{i + 1} - p_{i} = 1, 1 \le i \le k - 1$$$ is true, we can match $$$p_{i}$$$ with $$$p_{i + 2}$$$. The only other case is $$$k = 2$$$, for that it is simply $$$min(x, 2 * y)$$$.

Me being happy for everyone else while getting prolly -80 myself

this was a nice round. solved 3 ques of Div 2 for the very first time. feels good :)

and also can anyone tell me how to approach problem C.Thanks in advance

do l = 1 and r = n to make the edges equal then loop from 1+1 to n-1 using l = 1 and r = i to make either all evens or all odds equal to the edge then do the same from n-1 to 1+1 to make the opposite numbers this will make all the array entries equal didn't solve it yet but I think that is the correct answer.

yes,sounds correct.will implement it ,lets see how it goes thanks btw

D1 is like is it this easy, what the fuck?????

It's more like a second B problem

yes,same feeling .I checked if its a Div 2 or Div 4 contest lol

lol =)

When will be the editorial be uploaded for this contest ?

Great contest, interesting tasks, thanks!

I have managed to solve problem

D2withO(N)time complexity using simple dp.https://codeforces.com/contest/1733/submission/172742046

tlsdydaud1 I think it would be better to make

Nup to2e5, but anyway contest was great. Thanks for problems!Thanks for enjoying! Actually, some testers gave O(n) solution of D2 already, but we decided to accept O(n^2) solution for difficulty balance.

Submitted AC solution of D1 2 seconds after end of contest , sad

Nobody cares

This is my first contest. In contests this comes under unrated contest but the blog post says its rated. Can anyone clarify?

It's rated, but it takes some time for rating changes to apply, since there is system testing after the contest (which is already done for this one) and a procedure to find and remove cheaters (which can take quite a while). After that, the rating changes are applied and the contest should be moved to the rated contest list.

There are exceptional scenarios in which a contest that is supposed to be rated becomes unrated (such as when a problemsetter unethically copies a problem directly from another source), but I don't think there were any issues for this particular contest, so it should hopefully be rated. Just be patient...

Thanks

Until the rating changings will be done it is unrated (it usually takes about 12h-16h)

OperationForces

Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!

when will solution get available ?

For Problem B, I observed that either player 1 will win 0 matches or player 2 will win 0 matches.

That means for a valid solution either x has to be 0 or y has to be zero.

Am I correct?

yes

In D1 problem, I finded an bordercase.

I sended two codes and both receive Accepted. But the output for this input:

1 4 4 1 0110 0000

is different. The correct output is 3, but in the second submission the output is 4.

This special case is to n = 4, a2 != b2, a3 != b3 and x > 3y.

True. But n is guaranteed to be at least 5. So you can ignore this special case.

A memorable round for me!

All Top 10 USERS are newly registered except 1-2. this is so demotivated things I have seen on CF

.

How to Solve E,the last problem?

Cyan Gang finally

I was inspired by this question https://codeforces.com/contest/1728/problem/D ，and write the dp dp[l][r] from dp[l+2][r], dp[l][r-2],dp[l+1][r-1], but it failed. It seems be same as the dp like others, but it is sure may be wrong. my failed solution is https://codeforces.com/contest/1733/submission/172731642 , thanks for comments!

I solved this by change the initial DP, like this https://codeforces.com/contest/1733/submission/172778355

and the test date is: 1 6 100 1 111111 000000

As an expert, i messed up in this contest :((

Hey, how i can check all input for Problem A? im getting wrong in test 2 in the 158 exemple, but i can't see it because has some others before.[problem:A. Consecutive Sum — Round #821 (Div. 2)]

You can't. But your code fails in this test case :

it gives 21 as an answer but the wright answer should be 23.

Thanks for your help! I tried now with some repairs. In your example is giving 23. Now im stuck at example 427th lol. I started coding a few weeks ago, and i searching for new ways to solve the problems, but im trying to understand my mistakes in my logic at the contest

your code gives 2, but it should be 3.

I tried solving Problem D1, but getting wrong answer on 49th entry of test case 2, Please tell me where I am wrong....Please Help. I already did 9 wrong Submissions.

Here is a counterexample:

Your algorithm returns 3, but the correct answer is 2. You can simply apply the operation on indices $$$(1, 4)$$$ and then on $$$(1, 5)$$$. Index 1 flips twice, so it reverts to 0, while indices 4 and 5 each flip once and become 0. The cost is $$$2y = 2$$$, which is better than spending $$$x = 3$$$ cost on flipping $$$(4, 5)$$$ directly.

My code for problem D2 is giving Time Limit Exceeded at test case 3, Please help me in optimising my Approach, suggest me with this intution only, please help.

it was good . But I miss one condition in problem D.

Yeah same. Problems were fun though

Please upload the editorial !!! tlsdydaud1

Now editorial is available.

No tutorial?

Problem Eis quite beautiful. First we note, for each slime its sum of coordinates increases by 1 each step. So each diagonal can hold only one slime per timestep. So Slimes will never combine.Now we look at a modified game. Imagine there are $$$t-x-y$$$ slimes in $$$(0,0)$$$. We move them all at once. If there are $$$S(X,Y)$$$ slimes in $$$(X,Y)$$$, then $$$\left \lceil{S(X,Y)/2}\right \rceil $$$ will move to the right and $$$\left \lfloor{S(X,Y)/2}\right \rfloor $$$ will move down. This way in dp-style we can determine how many slimes $$$S(X,Y)$$$ will have passed through each field.

Now we start a lonely last heroic slime at $$$(0,0)$$$ and move it along the axes. It is the only one that possibly can fulfil the query (because, as we have noted, their sum of coordinates always increases by one). If $$$S(X,Y)$$$ is even, we move it to the right, because an even number of slimes passed this field so the conveyor will point to the right. If it is odd, we move the slime down. If it ever reaches $$$(x,y)$$$, then the answer is

YES. Else the answer isNO.See also here, my commented code: 172810570

Also here's a program and some snapshots to animate the state of the conveyor after each slime:

1k slimes50k slimesProgram for AnimationCould you please share the editorial?

My code for problem D2 is giving Time Limit Exceeded at test case 3, Please help me in optimising my Approach, suggest me with this intution only, please help.

good

yes

Can someone guide me how to increase my rating, what questions should I practice, what concepts should be focused, what should be my approach as a beginner I was not consistent earlier, but now I seek to grow.

LoL

Ah, yes. Here we go again! How can we prove that we didn`t cheated if the problem was very simple and we wrote some same fucking "for"s and "if"s? Please, can you do something about it? sadly I have no suggestions.

Внимание!

Ваше решение 172700828 по задаче 1733D1 значительным образом совпадает с решениями других участников и находится в группе одинаковых решений magnuscarlsum/172691072, allcasepass2/172699857, Daqlet/172700828, ashutosht-code1845/172701732, Willcheatyou/172703661, Eccentric_9/172704862, master_codencode/172707763, 3ayzMedal/172710754, abdelrahmanlotfy317/172712290, nithinkumar7070/172713581, rank01/172713911, manojkumar1438/172714519, Peeyush556/172715164, Ssr_536/172715571, aditya_ahlawat_1309/172715592, 2001atanughosh/172716000, 2000032121/172716579, SouvikCH/172716698, VeeraVamshi/172716771, comddingg/172717409, off_campus/172717545, new_start_for_win/172717554, lohith1216/172718150, gandesaikiran8902/172718165, Krilin/172719125, padmasai1216/172719379, praneethadevulapalli/172719576, Sase/172719821, 2000031362/172719887, rishav__01/172720183, abhinavvvv131/172720486, Kal.El/172721004, poojith_mannepalli/172721475, Rai_Utkarsh/172721634, klu_2000031535/172721653, Abhyudai_Mishra_2024/172721673, Twinkle_Star29/172721976, janender0707/172722279, sriya30295/172722593, CheatPlusPlus2/172722888, s23singh/172723100, yashika_03/172723830, KL_2000031102/172724435, oko053651/172725936, officialnj26/172726410, asal.jahanshiri/172726760, abhishek_090802/172727205, Raj088/172727415, suiiiii/172727578, pera2008/172727869, MananPopat/172728011, brainsoft/172728527, NoDrop30/172728830, dharabindal123/172728942, pasyanthi/172728989, azhakim/172729176, kl_2000032077/172729267, testac2/172729273, Sultanov_I/172729734, Parthverma22/172729855, ROBOSTAR/172730887, 2000031415JayanthKrishna/172731001, MomenSh306/172731333, Omar_Khaled_Me/172731412, Mohammd_Benni/172731596, Kither/172732436, ankitkr22201/172732495, Mohd_aman000/172732598, el_2000030813/172732819, uokeynoname/172733416, klh2010030535/172733528, Pranav1903/172733534, stunner2k22/172733859, Youssef_mkdaad/172734296, harshit0077/172734836, Coding1212/172734863, Sai_Chandu/172734996, kruthik/172735039, navneetguptacse/172735437, Pavan_Yaddanapudi/172735715, g_aadesh29/172735885, VLovesD/172735998, max_d/172736062, Pinakakali/172736150, umamhesh/172736756, 2010030159/172736858, xanaxrehabclub/172737066, ahmedfereg480/172737296, Kaustubh01/172737441, klu_2000031628/172737629, CeLLxMaTTriX/172737688, anujmishra/172737884, ishivchaudhary/172738211, Levii_Ackerman/172738319. Такое совпадение является явным нарушением правил. Отметим, что непреднамеренное утечка тоже является нарушением. Например, не следует пользоваться ideone.com с настройками по умолчанию (публичным доступом к вашему коду). Если вы имеете неоспоримые доказательства, что совпадение произошло по причине использования общего источника, опубликованного до соревнования, то напишите комментарий к посту о раунде со всеми деталями. Подробнее можно прочитать по ссылке http://codeforces.com/blog/entry/8790. Такое нарушение правил может являться основанием для блокировки вашего аккаунта или других штрафных санкций. В случае повторения нарушений, ваш аккаунт может быть заблокирован.

Regarding Similar Solution between ojasGupta/172672316, smit086/172709047. I think its mere coincidence that the codes where so similar, I havent cheated once and was only using vscode. Whereas the other person has been caught cheating multiple times. Please review.