A2186 | [USACO16DEC] Cow Checklist G
来源USACO / 2016
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
每天,农夫约翰走过他的牧场,检查他的每头奶牛的存在感。在他的农场,他有两个品种的牛,Holsteins和Guernseys。他的H Holsteins方便地编号为$1 \ldots H$,并且他的G Guernseys方便地编号为$1 \ldots G$($1 \leq H \leq 1000, 1 \leq G \leq 1000$)。每个牛位于2D平面中的点(不一定是不同的)。
农夫约翰从Holsteins 1出发,在Holsteins H结束。他想要沿途参观每头牛,为了方便保持他到目前为止访问的牛的清单,他想按他们的编号顺序访问Holsteins和Guernseys。在他访问的所有$H+G$头牛的序列中,Holsteins编号为$1 \ldots H$应该显示为(不一定是连续的)子序列,对于Guernseys也相同。换句话说,所有$H+G$牛的序列应该通过将编号为$1 \ldots H$的Holsteins列表与编号为$1 \ldots G$的Guernseys列表交错形成。
当FJ从一头母牛移动到另一头母牛,行进距离为$D$时,他消耗$D^2$能量。请帮助他确定访问所有奶牛所需的最低能量。
农夫约翰从Holsteins 1出发,在Holsteins H结束。他想要沿途参观每头牛,为了方便保持他到目前为止访问的牛的清单,他想按他们的编号顺序访问Holsteins和Guernseys。在他访问的所有$H+G$头牛的序列中,Holsteins编号为$1 \ldots H$应该显示为(不一定是连续的)子序列,对于Guernseys也相同。换句话说,所有$H+G$牛的序列应该通过将编号为$1 \ldots H$的Holsteins列表与编号为$1 \ldots G$的Guernseys列表交错形成。
当FJ从一头母牛移动到另一头母牛,行进距离为$D$时,他消耗$D^2$能量。请帮助他确定访问所有奶牛所需的最低能量。
输入格式
The first line of input contains $H$ and $G$, separated by a space.
The next $H$ lines contain the $x$ and $y$ coordinates of the $H$ Holsteins, and the next $G$ lines after that contain coordinates of the Guernseys. Each
coordinate is an integer in the range $0 \ldots 1000$.
The next $H$ lines contain the $x$ and $y$ coordinates of the $H$ Holsteins, and the next $G$ lines after that contain coordinates of the Guernseys. Each
coordinate is an integer in the range $0 \ldots 1000$.
输出格式
Write a single line of output, giving the minimum energy required for FJ's tour of all the cows.
输入输出样例
输入 #1
3 2 0 0 1 0 2 0 0 3 1 3
输出 #1
20
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted