CF374E.Inna and Babies

省选/NOI-

通过率:0%

时间限制:6.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Inna, Dima and Sereja are in one room together. It's cold outside, so Sereja suggested to play a board game called "Babies".

The babies playing board is an infinite plane containing n blue babies and m red ones. Each baby is a segment that grows in time. At time moment t the blue baby (x, y) is a blue segment with ends at points (x - t, y + t), (x + t, y - t). Similarly, at time t the red baby (x, y) is a red segment with ends at points (x + t, y + t), (x - t, y - t) of the plane. Initially, at time t = 0 all babies are points on the plane.

The goal of the game is to find the first integer moment of time when the plane contains a rectangle of a non-zero area which sides are fully covered by some babies. A side may be covered by multiple babies. More formally, each point of each side of the rectangle should be covered by at least one baby of any color. At that, you must assume that the babies are closed segments, that is, they contain their endpoints.

You are given the positions of all babies — help Inna and Dima to find the required moment of time.

因娜、迪马和谢尔盖一起待在同一个房间里。外面很冷,因此谢尔盖建议玩一款名为“宝宝”的棋盘游戏。

“宝宝”游戏的棋盘是一个无限平面,上面有 nn 个蓝色宝宝和 mm 个红色宝宝。每个宝宝是一条随时间增长的线段。在时刻 tt,蓝色宝宝 (x,y)(x, y) 是一条蓝色线段,其两个端点坐标为 (x−t,y+t)(x - t, y + t) 和 (x+t,y−t)(x + t, y - t);类似地,在时刻 tt,红色宝宝 (x,y)(x, y) 是一条红色线段,其两个端点坐标为 (x+t,y+t)(x + t, y + t) 和 (x−t,y−t)(x - t, y - t)。初始时刻 t=0t = 0 时,所有宝宝都退化为平面上的点。

游戏的目标是找出第一个整数时刻 tt,使得平面上存在一个面积非零的矩形,其四条边均被若干宝宝完全覆盖(一条边可被多个宝宝共同覆盖)。更准确地说:该矩形每条边上的每个点,都必须至少被一个(任意颜色)宝宝所覆盖。注意:此处所有宝宝均为闭线段,即包含其两个端点。

现给出所有宝宝的初始位置,请帮助因娜和迪马找出满足条件的最早时刻 tt。

输入格式

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 2000).

Next n lines contain the coordinates of the blue babies. The i-th line contains integers x__i, y__i — a baby's coordinates. Next m lines contain the coordinates of m red babies in the similar form.

All coordinates of the input don't exceed 106 in their absolute value. Note that all babies stand in distinct points.

输入的第一行包含两个整数 nn 和 mm(1 ≤ n, m ≤ 20001 \leq n, m \leq 2000)。

接下来的 nn 行包含蓝色婴儿的坐标。第 ii 行包含整数 xi, yix_i,\ y_i —— 一个婴儿的坐标。再接下来的 mm 行以类似形式给出 mm 个红色婴儿的坐标。

输入中所有坐标的绝对值均不超过 10610^6。注意:所有婴儿均位于互不相同的点上。

输出格式

In the single line print a single integer — the answer to the problem.

If the rectangle never appears on the plane, print "Poor Sereja!" without the quotes.

在单行中输出一个整数——即该问题的答案。

如果矩形永远不会出现在平面上,则输出 Poor Sereja!(不带引号)。

输入输出样例

  • 输入#1

    2 2
    2 2
    5 5
    3 7
    5 1

    输出#1

    3
  • 输入#2

    3 2
    2 2
    3 2
    6 2
    4 2
    5 2

    输出#2

    1

输入解题思路,AI测评打分。不知道怎么写?

首页