A9356 | Inna and Babies
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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 $10^{6}$ in their absolute value. Note that all babies stand in distinct points.
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 $10^{6}$ in their absolute value. Note that all babies stand in distinct points.
输出格式
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.
If the rectangle never appears on the plane, print "Poor Sereja!" without the quotes.
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted