CF120J.Minimum Sum
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
给你平面上的 $ n $ 个向量。对于每个向量,你可以将其任意一个坐标乘以 −1。因此,每个向量 $ v_i = (x_i, y_i) $ 可以被变换为以下四个向量之一:
- $ v_{i1} = (x_i, y_i) $,
- $ v_{i2} = (-x_i, y_i) $,
- $ v_{i3} = (x_i, -y_i) $,
- $ v_{i4} = (-x_i, -y_i) $.
你需要从该集合中选出两个向量,并确定对它们各自哪些坐标乘以 −1,使得所得两个向量之和的模长尽可能小。更准确地说,你需要选择两个向量 $ v_i 、 v_j $(其中 $ 1 \le i, j \le n $,且 $ i \ne j $)以及两个整数 $ k_1 、 k_2 $(其中 $ 1 \le k_1, k_2 \le 4 $),使得表达式 $ |v_{ik_1} + v_{jk_2}| $ 的值最小。
输入格式
The first line contains a single integer n (2 ≤ n ≤ 105). Then n lines contain vectors as pairs of integers "x__i y__i" ( - 10000 ≤ x__i, y__i ≤ 10000), one pair per line.
第一行包含一个整数 n(2≤n≤105)。接下来的 n 行每行包含一个向量,以整数对 “xi yi” 的形式给出(−10000≤xi,yi≤10000),每行一对。
输出格式
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.
在第一行输出四个用空格分隔的数字 “i _k_1 j _k_2”——即该问题的答案。如果存在多个绝对值之和最小的方案,你可以输出其中任意一个。
输入输出样例
输入#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).
向量 v=(xv,yv) 与向量 u=(xu,yu) 的和为向量 s=v+u=(xv+xu,yv+yu)。
向量 v=(x,y) 的模(绝对值)为数
。
在第二个样例中,存在多个合法答案,例如:
(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)。
输入解题思路,AI测评打分。不知道怎么写?