All solutions are 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 a solution for 701E (could not figure out on my own) really helped me understand the problems better. 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 with comments. 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 A LOT of detail if you're not so good at working with trees. Here's my implementation of the editorial solution.