All solutions below are thoroughly commented and based on the official editorial. I might start doing this for one or two editorials every month starting now because writing alternate solutions for 701C and 701D and writing solutions for 701E and 701F (could not figure out on my own) really helped me understand the problems better. Also, I'm sorry if the later solutions are more clunky; I'm not used to solving problems of that difficulty. Thanks!
701A — Cards
Their explanation is pretty straight-forward, so here's the solution.
701B — Cells Not Under Attack
Here, I deviate from the editorial in two ways:
- Because I am using C and do not have
set
, I instead mark rows and columns as attacked in an array ofbool
s and count the number of attacked rows and columns as I go along. - Their formula is n·n - cnt where cnt = szY·n + szX·n - szX·szY. This gives us n·n - szY·n - szX·n + szX·szY = (n - szX)(n - szY). I use the latter in my solution.
Here is my solution for this problem.
701C — They Are Everywhere
The confusing part of their answer is that they're not really clear about when they're talking about looping through the different types of letters in s
or all of the letters in order. Here is my implementation of their solution.
701D — As Fast As Possible
Here is my binary search solution. The problem with their explanation here is it's out of order, they never actually show their equation for what I called x, their variable posM convoluted their formula for x, and they never actually solve for what I called y but instead briefly mentions to account for the bus going back.
701E — Connecting Universities
I think the way they explained 701E pretty well other than the fact that lv is unnecessary since lv = 1 for all v. However, it is missing lots of detail if you're not so good at working with trees. Here's my implementation of the editorial solution.
701F — Break Up
I could not understand from the editorial's explanation how to find the second edge in the case of two edges until I looked at the dfs2()
function from this solution to 701F from Vosatorp, so thanks to them for this solution! Here is my re-writing of Vosatorp's solution in C, without vector
.
700D — Huffman Coding on Segment
Coming soon!
700E — Huffman Coding on Segment
Coming soon!