A8347 | Minimum Sum
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a set of $n$ vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector $v_{i}=(x_{i},y_{i})$ can be transformed into one of the following four vectors:
- $v_{i}^{1}=(x_{i},y_{i})$ ,
- $v_{i}^{2}=(-x_{i},y_{i})$ ,
- $v_{i}^{3}=(x_{i},-y_{i})$ ,
- $v_{i}^{4}=(-x_{i},-y_{i})$ .
You should find two vectors from the set and determine which of their coordinates should be multiplied by -1 so that the absolute value of the sum of the resulting vectors was minimally possible. More formally, you should choose two vectors $v_{i}$ , $v_{j}$ ( $1<=i,j<=n,i≠j$ ) and two numbers $k_{1}$ , $k_{2}$ ( $1<=k_{1},k_{2}<=4$ ), so that the value of the expression $|v_{i}^{k_{1}}+v_{j}^{k_{2}}|$ were minimum.
- $v_{i}^{1}=(x_{i},y_{i})$ ,
- $v_{i}^{2}=(-x_{i},y_{i})$ ,
- $v_{i}^{3}=(x_{i},-y_{i})$ ,
- $v_{i}^{4}=(-x_{i},-y_{i})$ .
You should find two vectors from the set and determine which of their coordinates should be multiplied by -1 so that the absolute value of the sum of the resulting vectors was minimally possible. More formally, you should choose two vectors $v_{i}$ , $v_{j}$ ( $1<=i,j<=n,i≠j$ ) and two numbers $k_{1}$ , $k_{2}$ ( $1<=k_{1},k_{2}<=4$ ), so that the value of the expression $|v_{i}^{k_{1}}+v_{j}^{k_{2}}|$ were minimum.
输入格式
The first line contains a single integer $n$ ( $2<=n<=10^{5}$ ). Then $n$ lines contain vectors as pairs of integers " $x_{i}$ $y_{i}$ " ( $-10000<=x_{i},y_{i}<=10000$ ), one pair per line.
输出格式
Print on the first line four space-separated numbers " $i$ $k_{1}$ $j$ $k_{2}$ " — the answer to the problem. If there are several variants the absolute value of whose sums is minimum, you can print any of them.
输入输出样例
输入 #1
5 -7 -3 9 0 -8 6 7 -8 4 -5
输出 #1
3 2 4 2
输入 #2
5 3 2 -4 7 -6 0 -8 4 5 1
输出 #2
3 4 5 4
A sum of two vectors $v=(x_{v},y_{v})$ and $u=(x_{u},y_{u})$ is vector $s=v+u=(x_{v}+x_{u},y_{v}+y_{u})$ .
An absolute value of vector $v=(x,y)$ is number .
In the second sample there are several valid answers, such as:
(3 1 4 2), (3 1 4 4), (3 4 4 1), (3 4 4 3), (4 1 3 2), (4 1 3 4), (4 2 3 1).
An absolute value of vector $v=(x,y)$ is number .
In the second sample there are several valid answers, such as:
(3 1 4 2), (3 1 4 4), (3 4 4 1), (3 4 4 3), (4 1 3 2), (4 1 3 4), (4 2 3 1).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted