Could you please tell me how to solve problem B (Breaking Biscuits) in the gym contest http://codeforces.com/gym/101606 ?

Thanks

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

1 | tourist | 3882 |

2 | maroonrk | 3539 |

3 | Benq | 3513 |

4 | MiracleFaFa | 3466 |

5 | ksun48 | 3462 |

6 | ecnerwala | 3446 |

7 | slime | 3428 |

8 | Um_nik | 3426 |

9 | jiangly | 3401 |

10 | greenheadstrange | 3393 |

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

1 | awoo | 192 |

2 | -is-this-fft- | 191 |

3 | Monogon | 184 |

4 | YouKn0wWho | 182 |

4 | Um_nik | 182 |

6 | antontrygubO_o | 171 |

7 | maroonrk | 169 |

8 | kostka | 165 |

9 | SecondThread | 164 |

9 | errorgorn | 164 |

Could you please tell me how to solve problem B (Breaking Biscuits) in the gym contest http://codeforces.com/gym/101606 ?

Thanks

↑

↓

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/24/2022 21:39:11 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

I think you just need to find convex hull (Graham scan for example). Than you have to find for each point of convex hull the point which is furthest from it (Rotating calipers technique —

O(n) or ternary search —O(nlogn)). The answer is minimum of these distances.Could you please elaborate more?

First you create convex hull (just use one algorithm) and sort them in clockwise order. Then for the first point you check all other points and take the one with maximum distance (also you must save the index of this point). And then since polygon is convex when searching for next maximum (for point that is next in clockwise order), you can go around the polygon clockwise ans while next point (starting from index saved before) is further, increase index. Complexity of creating convex hull is

O(nlogn) and you can find these distances inO(n) because you will go at most one circle around convex hull polygon.If for each point, we find the point farthest from it, and take the minimum over all these maximum distances, there may still be a better solution. You only need to consider the first sample to see this. The sample is a rectangle of height = 5 and width = 2. The farthest point from each vertex is always on the diagonal. However, we can just place the rectangle inside a cup with diameter of 2. (place the rectangle with the long side parallel to the cup).

The correct solution is VladaMG98's.

It is always optimal to place the polygon with one edge parallel to the cup. Note that if we have a solution where this is not the case, we can rotate the polygon so that a side is touching the side of the cup which will give us a better answer (draw some pictures to convince yourselves. We can try placing any edge on the side of the cup, and for each find the vertex farthest away from it.

Input sizes are so small we can do N^2 solution very easily. You still need Convex Hull for this. Since N is at most 100, we can do an N^3 solution without using convex hull at all just to make coding easier. It's a similar idea. Try figuring it out if you want.

You are right. For every edge we must find the point which is furthest from our edge (the line on which our edge lies) and than take minimum of these distances. Although everything else is the same.

For every edge, you need to find the furthest vertex to that edge, and then just take the minimum of all of those distances.

Could you please elaborate more?

Here is the editorial.

There is not only convex polygon allows in task. Does it correct for polygon with heart shape where height is more less then wide? It seems we can construct such shape that answer is only heart height (no rotation), but any rotation will increase height.

I have probably made a mistake, never mind.