a codeforces contest.

A. Divisible Permutation

just do it https://codeforces.com/contest/2188/submission/368936553

B. Seats

I actually sillied here and thought the contribution of a segment was 𝑙2 rather than 𝑙3…bad looks.

C. Restricted Sorting

we can freely rearrange all values in the range [1,mx𝑘] among themselves

also note that if there exists 𝑣 such that mn+𝑘>𝑣 and mx𝑘<𝑣, this value can never be moved. otherwise, conjecture that all other values may be freely rearranged?

proof: we can always move either mn to mx to a non-stuck index. we can then swap this to either mn or mx if needed, then swap with the desired value.

https://codeforces.com/contest/2188/submission/368940046

D. Shortest Statement Ever

answer bounded by min(𝑥,𝑦) because we can just set either 𝑝 or 𝑞 to 0

(after consulting editorial, this doesn’t look like a very good problem…)

E. Jerry and Tom

Tom will win for sure if his shortest path to destination is Jerry’s

otherwise, I think Jerry always wins

(consulted editorial…solution is fairly nice, should probably better formalize optimal strategies when thinking about game problems in the future)

games

F. Cool Problem

(consulted editorial)

kind of cool I guess? still rather contrived though…

1E. Doors and Keys

1 0 1 1 1 4 0 2 0 3 0 14 0 10 18 7 25

1110000001

dp on rightmost unlocked door, current pos value = minimum time to reach?

(read editorial)

i missed an observation: if going back for a key, it’s actually better to drag the keys along with you in order to maximize time of arrival of first key better chance that the door has already been unlocked

formally if you pass a key and come back for it later, you’d rather swap the moves so that you come back for it now

therefore, we basically only need to consider moving to the right but with the extra cost of dragging along keys (2𝑘1 if we are carrying 𝑘 keys)

finally, note that we should never carry more than 𝑉 keys because it will take at least 𝑂(𝑉) time to get rid of all the keys, after which we could just wait for all the doors to open

star

Final Thoughts

IMO a pretty mid contest aside from Doors and Keys and Restricted Sorting