Today due to a power outage there may be disruptions in the work of Codeforces and Polygon. Please do not plan any important events during this time. If there are details or the exact time, we will definitely publish them. Estimated time of maintenance: from 3 Aug, 14:30 (UTC) to 3 Aug, 18:00 (UTC).
×

# | User | Rating |
---|---|---|

1 | tourist | 3819 |

2 | Benq | 3745 |

3 | ksun48 | 3560 |

4 | Radewoosh | 3511 |

5 | Um_nik | 3489 |

6 | peehs_moorhsum | 3460 |

7 | Petr | 3414 |

8 | Miracle03 | 3410 |

9 | maroonrk | 3400 |

10 | sunset | 3338 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 208 |

2 | awoo | 182 |

3 | Errichto | 180 |

4 | Um_nik | 179 |

5 | -is-this-fft- | 174 |

5 | maroonrk | 174 |

7 | Radewoosh | 172 |

7 | tourist | 172 |

9 | SecondThread | 170 |

10 | rng_58 | 166 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/03/2021 17:05:31 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

How to solve problem H pivoting point?

Particularly, there's a "p-dk.cc" in the official solution package [1]. Its logic looks much simpler than the editorial, but I don't understand why it works. Meanwhile, a bunch of submissions seem to follow the same logic. Could somebody explain it to me?

[1] http://www.acmicpc-pacnw.org/ProblemSet/2019/editorial.zip

The first insight for the problem is that if we consider the current state of our windmill procedure to be described by $$$k$$$, the number of points to the left of the current line (passing through some arbitrary point), then all states with equal values of $$$k$$$ are reachable from each other, and the procedure will pass through all such states once before revisiting any.

We can see that more intuitively by seeing that if we have a line of slope $$$m$$$, then there are no more than 2 states with a given $$$k$$$. If $$$n$$$ is odd and $$$k$$$ is $$$(n-1)/2$$$, then there's just one solution passing through that point (but really it's two overlapping solutions with flipped orientation). (If that's not obvious, try drawing some vertical lines and sweep them along a bunch of points).

Another observation is that the windmill motion preserves the value of $$$k$$$, since when we change pivots, we always lose a point from one side (the newly promoted pivot) and gain a pivot on that same side (the demoted pivot). Again, this might take some examples to fully get.

Since the windmill motion is continuous and monotonically increasing the angle, during the process of spinning through 360º, we must transition only to other states with equal values of $$$k$$$ with lines of increasing angles, so we can't miss any or hit any twice either. (Actually this might not be that rigorous so please correct me if I'm wrong)

Now, to answer the original problem, we can essentially do the same idea as swapping the order of summation. Instead of simulating the windmill process for all values of $$$k$$$ and finding the maximum promotion count for all points in the process, we can just look from each point's perspective and see how many times it gets promoted for each state of a given $$$k$$$.

For any pivot point, it can get promoted when a line passing through one of the other $$$n-1$$$ points hits it.

Now, to cleanly go through all possible lines that hit our pivot, we just do the easiest thing possible! Consider the perspective of the pivot and just rotate through through 360º, treating the pivot as the origin. A line connecting our pivot to another point corresponds to some promotion event. Note, since the line extends from both directions of the pivot, we can rotate points that have angle > 180º by flipping them 180º.

Now, we just need to go through these points and track how many are on the left side, and any time we see a point that wasn't mirrored, then it gets moved to the right side, and the opposite if it was flipped. Remember every point has two solutions, so we need to go through this process again, but reversing the orientation. Throughout this process, we can track the number of promotions the pivot receives for states of a given $$$k$$$ in $$$promotion[k]$$$, and we maximize our answer over $$$promotion$$$ for all pivots to get the answer.

Hope that made sense!

(Also I didn’t really understand the binary search solution so if someone could explain that that’d be great)

In problem G, my code got accepted assuming that there can be only one pulse on a wire throughout the time. I wonder how to solve this problem when there can be multiple pulses going through a wire.