A8842 | Building Bridge
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Two villages are separated by a river that flows from the north to the south. The villagers want to build a bridge across the river to make it easier to move across the villages.
The river banks can be assumed to be vertical straight lines $x=a$ and $x=b$ ( $0<a<b$ ).
The west village lies in a steppe at point $O=(0,0)$ . There are $n$ pathways leading from the village to the river, they end at points $A_{i}=(a,y_{i})$ . The villagers there are plain and simple, so their pathways are straight segments as well.
The east village has reserved and cunning people. Their village is in the forest on the east bank of the river, but its exact position is not clear. There are $m$ twisted paths leading from this village to the river and ending at points $B_{i}=(b,y'_{i})$ . The lengths of all these paths are known, the length of the path that leads from the eastern village to point $B_{i}$ , equals $l_{i}$ .
The villagers want to choose exactly one point on the left bank of river $A_{i}$ , exactly one point on the right bank $B_{j}$ and connect them by a straight-line bridge so as to make the total distance between the villages (the sum of $|OA_{i}|+|A_{i}B_{j}|+l_{j}$ , where $|XY|$ is the Euclidean distance between points $X$ and $Y$ ) were minimum. The Euclidean distance between points $(x_{1},y_{1})$ and $(x_{2},y_{2})$ equals .
Help them and find the required pair of points.
The river banks can be assumed to be vertical straight lines $x=a$ and $x=b$ ( $0<a<b$ ).
The west village lies in a steppe at point $O=(0,0)$ . There are $n$ pathways leading from the village to the river, they end at points $A_{i}=(a,y_{i})$ . The villagers there are plain and simple, so their pathways are straight segments as well.
The east village has reserved and cunning people. Their village is in the forest on the east bank of the river, but its exact position is not clear. There are $m$ twisted paths leading from this village to the river and ending at points $B_{i}=(b,y'_{i})$ . The lengths of all these paths are known, the length of the path that leads from the eastern village to point $B_{i}$ , equals $l_{i}$ .
The villagers want to choose exactly one point on the left bank of river $A_{i}$ , exactly one point on the right bank $B_{j}$ and connect them by a straight-line bridge so as to make the total distance between the villages (the sum of $|OA_{i}|+|A_{i}B_{j}|+l_{j}$ , where $|XY|$ is the Euclidean distance between points $X$ and $Y$ ) were minimum. The Euclidean distance between points $(x_{1},y_{1})$ and $(x_{2},y_{2})$ equals .
Help them and find the required pair of points.
输入格式
The first line contains integers $n$ , $m$ , $a$ , $b$ ( $1<=n,m<=10^{5}$ , $0<a<b<10^{6}$ ).
The second line contains $n$ integers in the ascending order: the $i$ -th integer determines the coordinate of point $A_{i}$ and equals $y_{i}$ ( $|y_{i}|<=10^{6}$ ).
The third line contains $m$ integers in the ascending order: the $i$ -th integer determines the coordinate of point $B_{i}$ and equals $y'_{i}$ ( $|y'_{i}|<=10^{6}$ ).
The fourth line contains $m$ more integers: the $i$ -th of them determines the length of the path that connects the eastern village and point $B_{i}$ , and equals $l_{i}$ ( $1<=l_{i}<=10^{6}$ ).
It is guaranteed, that there is such a point $C$ with abscissa at least $b$ , that $|B_{i}C|<=l_{i}$ for all $i$ $(1<=i<=m)$ . It is guaranteed that no two points $A_{i}$ coincide. It is guaranteed that no two points $B_{i}$ coincide.
The second line contains $n$ integers in the ascending order: the $i$ -th integer determines the coordinate of point $A_{i}$ and equals $y_{i}$ ( $|y_{i}|<=10^{6}$ ).
The third line contains $m$ integers in the ascending order: the $i$ -th integer determines the coordinate of point $B_{i}$ and equals $y'_{i}$ ( $|y'_{i}|<=10^{6}$ ).
The fourth line contains $m$ more integers: the $i$ -th of them determines the length of the path that connects the eastern village and point $B_{i}$ , and equals $l_{i}$ ( $1<=l_{i}<=10^{6}$ ).
It is guaranteed, that there is such a point $C$ with abscissa at least $b$ , that $|B_{i}C|<=l_{i}$ for all $i$ $(1<=i<=m)$ . It is guaranteed that no two points $A_{i}$ coincide. It is guaranteed that no two points $B_{i}$ coincide.
输出格式
Print two integers — the numbers of points on the left (west) and right (east) banks, respectively, between which you need to build a bridge. You can assume that the points on the west bank are numbered from $1$ to $n$ , in the order in which they are given in the input. Similarly, the points on the east bank are numbered from $1$ to $m$ in the order in which they are given in the input.
If there are multiple solutions, print any of them. The solution will be accepted if the final length of the path will differ from the answer of the jury by no more than $10^{-6}$ in absolute or relative value.
If there are multiple solutions, print any of them. The solution will be accepted if the final length of the path will differ from the answer of the jury by no more than $10^{-6}$ in absolute or relative value.
输入输出样例
输入 #1
3 2 3 5 -2 -1 4 -1 2 7 3
输出 #1
2 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted