Hi. Today i tried to solve 598F - Cut Length. There is an editorial. However as a pupil i did not get anything from that. So any idea would be appreciated how to solve it. Thank you in advance.

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

1 | Radewoosh | 3759 |

2 | orzdevinwang | 3697 |

3 | jiangly | 3662 |

4 | Benq | 3644 |

5 | -0.5 | 3545 |

6 | ecnerwala | 3505 |

7 | tourist | 3486 |

8 | inaFSTream | 3478 |

9 | maroonrk | 3454 |

10 | Rebelz | 3415 |

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

1 | adamant | 173 |

2 | awoo | 167 |

3 | SecondThread | 163 |

4 | BledDest | 162 |

4 | Um_nik | 162 |

6 | maroonrk | 161 |

6 | nor | 161 |

8 | -is-this-fft- | 150 |

9 | Geothermal | 146 |

10 | TheScrasse | 143 |

Hi. Today i tried to solve 598F - Cut Length. There is an editorial. However as a pupil i did not get anything from that. So any idea would be appreciated how to solve it. Thank you in advance.

↑

↓

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/02/2023 02:34:37 (k3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

We basically need to find the length of the common part between a line

ABand a polygonP.First for each line

XYin polygonP, compute the intersection point betweenABandXY.These are the points where the line either

entersthe polygon orleavesthe polygon.Sort these points according to

their order on the line(based on their distance fromAor distance fromB).Your answer is the sum of distance between each

Entering pointand its immediate nextLeaving Pointin this order.This is the basic idea. But the implementation can be quite tricky, since

vertex pointsmay occurtwiceas intersection points and180-degree anglesare allowed in the input. If you can't figure it out on your own, just look into someone else's code.