Binlogs
27 subscribers
18 photos
125 links
Download Telegram
read the docs.
Binlogs
https://codeforces.com/contests/2127
A.
the only case that satisfies this condition for all elements is: MEX(ai,ai+1,ai+2) = MAX(ai, ai+1, ai+2) - MIN(ai,ai+1,ai+2) = 0.

thus for the answer to be yes all the numbers must be the same and that number should be > 0.


B.

consider this, the second player teleports to the nearest wall in either direction if there is no wall on that direction he escapes.

approach:
if initially there is no wall or the person is at the start or at the end, then it will take him 1 day.

else the first person can choose either direction from the second person to put a wall and either case he will choose the one that is the nearest to the second person.

so based on that, the answer is going to be :
left_tot = count starting from the first until we reach the wall that is nearest to the second person.
right_tot = count starting from the end until we reach the wall that is nearest to the second person.
left_extra = the space between the left nearest wall and the second person.
right_extra = the space between the right nearest wall and the second person.

MAX(MIN(left_tot, right_tot + right_extra), MIN(right_tot, left_tot + left_extra)) + 1

when we add the `extra`s, we are saying the first person chooses that side and the second person is choosing the way which results the minimum day.

and then when we choose the maximum out of both, we are saying the first person won't let the second person leave with the minimum.

we are adding 1. because the first person always adds a wall, thus the second person has to remove that wall and wait until the next day to decide. therefore there is always a day he has to wait.

C.
couldn't do it.

#contest_analysis
πŸ‘1
Forwarded from αŒ‰αŒ‰α‰΅'s Journey (Freab)
Binlogs
https://atcoder.jp/contests/abc419
A.
straight forward. no explanation

B.
there are two operations 1. add a ball to the bag 2. pop out the smallest ball out of the bag.

use priority queue (heap)

C.
the optimal position to be is at the center.
then we just have to find the center and the time it takes to get there.
on the x-coordinate the center can be found using the minimum and maximum values found out of the x-coordinates.
on the y-coordinate, we can just use the same technique.

then which ever coordinate takes the longest to reach their center is the answer.

D.
we are given two same length strings. and we have to swap characters between some segments with the two strings. we have to return the first string after all the swap operations are done.

we can use a prefix sum to accumulate the swaps and do just one swap at the end.
after we have the prefix sum, we will do the swap for the indices that we have to swap and return the first string.

#contest_analysis