P4758 [CERC2014] Mountainous landscape

题目描述

You travel through a scenic landscape consisting mostly of mountains – there are $n$ landmarks (peaks and valleys) on your path. You pause for breath and wonder: which mountain are you currently seeing on the horizon? ![0](https://cdn.luogu.com.cn/upload/pic/23379.png) Formally: you are given a polygonal chain $P_1,P_2,\cdots,P_n$ in the plane. The $x$ coordinates of the points are in strictly increasing order. For each segment $P_i P_{i+1}$ of this chain, find the smallest index $j > i$, for which any point of $P_j P_{j+1}$ is visible from $P_i P_{i+1}$ (lies **strictly above** the ray $P_i \ P^{\rightarrow}_{i+1}$).

输入格式

输出格式