A10769 | Intranet of Buses
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A new bus route is opened in the city . The route is a closed polygon line in the place, with all segments parallel to one of the axes. $m$ buses will operate on the route. All buses move in a loop along the route in the same direction with equal constant velocities (stopping times are negligible in this problem).
Buses start their movement in the first vertex of the route with equal interval. Suppose that $T$ is the total time for a single bus to travel the whole loop of the route. Then, the bus 1 starts moving at time 0, the bus 2 starts at time $T/m$ , the bus 3 starts at time $2T/m$ , and so on; finally, the bus $m$ starts moving at time $(m-1)T/m$ . Thus, all intervals between pairs of consecutive buses (including the interval between the last and the first bus) are equal.
Buses can communicate with each other via wireless transmitters of equal power. If the transmitters have power $D$ , then only buses within distance $D$ of each other can communicate.
The buses are also equipped with a distributed system of schedule tracking. For all buses to stick to the schedule, the system has to synchronize the necessary data between all buses from time to time. At the moment of synchronization, the bus 1 communicates with the bus 2, the bus 2 — with bus 3, and so on; also, the bus $m$ communicates with the bus 1.
As a research employee, you are tasked with finding the smallest value of $D$ such that it is possible to find a time moment to perform synchronization once all buses have started moving.
Buses start their movement in the first vertex of the route with equal interval. Suppose that $T$ is the total time for a single bus to travel the whole loop of the route. Then, the bus 1 starts moving at time 0, the bus 2 starts at time $T/m$ , the bus 3 starts at time $2T/m$ , and so on; finally, the bus $m$ starts moving at time $(m-1)T/m$ . Thus, all intervals between pairs of consecutive buses (including the interval between the last and the first bus) are equal.
Buses can communicate with each other via wireless transmitters of equal power. If the transmitters have power $D$ , then only buses within distance $D$ of each other can communicate.
The buses are also equipped with a distributed system of schedule tracking. For all buses to stick to the schedule, the system has to synchronize the necessary data between all buses from time to time. At the moment of synchronization, the bus 1 communicates with the bus 2, the bus 2 — with bus 3, and so on; also, the bus $m$ communicates with the bus 1.
As a research employee, you are tasked with finding the smallest value of $D$ such that it is possible to find a time moment to perform synchronization once all buses have started moving.
输入格式
The first line contains two integers $n$ and $m$ ( $2<=n,m<=10^{5}$ ) — the number of vertices of the polygonal line, and the number of buses respectively.
Next $n$ lines describe the vertices of the route in the traversing order. Each of these lines contains two integers $x_{i}$ , $y_{i}$ ( $-1000<=x_{i},y_{i}<=1000$ ) — coordinates of respective vertex.
It is guaranteed that each leg of the route (including the leg between the last and the first vertex) is paralles to one of the coordinate axes. Moreover, no two subsequent vertices of the route coincide. The route is allowed to have self-intersections, and travel along the same segment multiple times.
Next $n$ lines describe the vertices of the route in the traversing order. Each of these lines contains two integers $x_{i}$ , $y_{i}$ ( $-1000<=x_{i},y_{i}<=1000$ ) — coordinates of respective vertex.
It is guaranteed that each leg of the route (including the leg between the last and the first vertex) is paralles to one of the coordinate axes. Moreover, no two subsequent vertices of the route coincide. The route is allowed to have self-intersections, and travel along the same segment multiple times.
输出格式
Print one real number — the answer to the problem. Your answer will be accepted if the relative or the absolute error doesn't exceed $10^{-6}$ .
输入输出样例
输入 #1
4 2 0 0 0 1 1 1 1 0
输出 #1
1.000000000
输入 #2
2 2 0 0 1 0
输出 #2
0.000000000
Suppose that each bus travel 1 distance unit per second.
In the first sample case, in 0.5 seconds buses will be at distance 1, hence we can choose $D=1$ .
In the second sample case, in 0.5 seconds both buses will be at $(0.5,0)$ , hence we can choose $D=0$ .
In the first sample case, in 0.5 seconds buses will be at distance 1, hence we can choose $D=1$ .
In the second sample case, in 0.5 seconds both buses will be at $(0.5,0)$ , hence we can choose $D=0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted