CF666D.Chain Reaction
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a plate, can run a powerful chain reaction under certain conditions.
To be precise, researchers introduced a rectangular Cartesian coordinate system on a flat plate and selected four distinct points with integer coordinates where bots will be placed initially. Next each bot will be assigned with one of the four directions (up, down, left or right) parallel to the coordinate axes. After that, each bot is shifted by an integer distance (which may be different for different bots) along its direction. The chain reaction starts, if the bots are in the corners of a square with positive area with sides parallel to the coordinate axes. Each corner of the square must contain one nanobot. This reaction will be stronger, if bots spend less time to move. We can assume that bots move with unit speed. In other words, the lesser is the maximum length traveled by bot, the stronger is reaction.
Scientists have prepared a set of plates and selected starting position for the bots for each plate. Now they ask you to assign the direction for each bot to move after landing such that the maximum length traveled by bot is as small as possible.
与您有着密切业务往来的贝尔兰科学家小组正在开展和平核能领域的研究。特别地,他们发现:在平板表面放置四个纳米机器人,在特定条件下可引发一次强大的链式反应。
具体而言,研究人员在平板上建立了一个矩形笛卡尔坐标系,并选取了四个具有整数坐标的互异点作为机器人的初始位置。随后,为每个机器人分配四个方向之一(上、下、左或右),且该方向必须平行于坐标轴。接着,每个机器人沿其指定方向移动一个整数距离(不同机器人移动的距离可以不同)。当且仅当四个机器人最终恰好位于一个面积为正、边与坐标轴平行的正方形的四个顶点上时,链式反应才会被触发;且正方形的每个顶点上必须恰好有一个纳米机器人。反应强度与机器人运动所耗时间成反比——我们假设所有机器人均以单位速度运动,因此反应越强,意味着所有机器人中最大移动距离越小。
科学家们已准备了一批平板,并为每块平板确定了机器人的初始位置。现在,他们请您为每个机器人指定落地后应移动的方向,使得所有机器人中最大移动距离尽可能小。
输入格式
The first line contains an integer number t (1 ≤ t ≤ 50) — the number of plates.
t descriptions of plates follow. A description of each plate consists of four lines. Each line consists of a pair of integers numbers x__i, y__i ( - 108 ≤ x__i, y__i ≤ 108) — coordinates of the next bot. All bots are in different locations.
Note, though, the problem can include several records in one test, you can hack other people's submissions only with the test of one plate, i.e. parameter t in a hack test should be equal to 1.
第一行包含一个整数 t(1≤t≤50)—— 表示盘子的数量。
接下来是 t 个盘子的描述。每个盘子的描述由四行组成,每行包含一对整数 xi,yi(−108≤xi,yi≤108)—— 表示下一个机器人的坐标。所有机器人都位于不同的位置。
注意:尽管本题的测试数据中可能包含多个盘子的记录,但你仅能使用单个盘子的测试数据来对其他人的提交进行 Hack;即 Hack 测试中的参数 t 必须等于 1。
输出格式
Print answers for all plates separately. First goes a single integer number in a separate line. If scientists have made an unfortunate mistake and nanobots are not able to form the desired square, print -1. Otherwise, print the minimum possible length of the longest bot's path.
If a solution exists, in the next four lines print two integer numbers — positions of each bot after moving. Print bots' positions in the order they are specified in the input data.
If there are multiple solution, you can print any of them.
分别输出所有培养皿的答案。首先,在单独的一行中输出一个整数。如果科学家犯了不幸的错误,纳米机器人无法构成所期望的正方形,则输出 -1;否则,输出最长机器人路径的最小可能长度。
如果存在解,则在接下来的四行中,每行输出两个整数——即每个机器人移动后的位置。机器人的位置需按输入数据中指定的顺序输出。
若存在多个解,可输出其中任意一个。
输入输出样例
输入#1
2 1 1 1 -1 -1 1 -1 -1 1 1 2 2 4 4 6 6
输出#1
0 1 1 1 -1 -1 1 -1 -1 -1
输入解题思路,AI测评打分。不知道怎么写?