051. The Convergence of Two Tetra-sided Polygons, Known as Rectangles

Codeforces
IDCF10269051
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You will be given two opposite corners of two separate rectangles and you must determine whether they intersect or not. The first line will contain 4 integers separated by spaces, which respectively represent the x-coordinate and y-coordinate of a corner of the rectangle and the x-coordinate and y-coordinate of the opposite corner. The second line will contain another 4 integers that represent the same coordinates but for the second rectangle. Print "YES" (without the quotes) if the rectangles intersect or "NO" (without the quotes) if the rectangles do not intersect. The first rectangle has one corner located at (-5,-5) and the opposite corner at (5,5). The second rectangle has one corner located at (4,4) and the opposite corner at (8,8). These rectangles intersect, thus "YES" is printed Also, if the rectangles lie on top of one another, they are intersecting. If one is inside the other and their perimeters do not touch, then they are not intersecting. ## Input The first line will contain 4 integers separated by spaces, which respectively represent the x-coordinate and y-coordinate of a corner of the rectangle and the x-coordinate and y-coordinate of the opposite corner. The second line will contain another 4 integers that represent the same coordinates but for the second rectangle. ## Output Print "YES" (without the quotes) if the rectangles intersect or "NO" (without the quotes) if the rectangles do not intersect. [samples] ## Note The first rectangle has one corner located at (-5,-5) and the opposite corner at (5,5). The second rectangle has one corner located at (4,4) and the opposite corner at (8,8). These rectangles intersect, thus "YES" is printedAlso, if the rectangles lie on top of one another, they are intersecting. If one is inside the other and their perimeters do not touch, then they are not intersecting.
**Definitions** Let $ R_1 = [x_{1,\min}, x_{1,\max}] \times [y_{1,\min}, y_{1,\max}] $ and $ R_2 = [x_{2,\min}, x_{2,\max}] \times [y_{2,\min}, y_{2,\max}] $ be two axis-aligned rectangles, where: - $ x_{1,\min} = \min(a_1, a_3) $, $ x_{1,\max} = \max(a_1, a_3) $, - $ y_{1,\min} = \min(a_2, a_4) $, $ y_{1,\max} = \max(a_2, a_4) $, - $ x_{2,\min} = \min(b_1, b_3) $, $ x_{2,\max} = \max(b_1, b_3) $, - $ y_{2,\min} = \min(b_2, b_4) $, $ y_{2,\max} = \max(b_2, b_4) $, with input coordinates $ (a_1, a_2, a_3, a_4) $ for $ R_1 $ and $ (b_1, b_2, b_3, b_4) $ for $ R_2 $. **Constraints** All coordinates are integers. **Objective** Determine whether $ R_1 \cap R_2 \neq \emptyset $. That is, output "YES" if: $$ \max(x_{1,\min}, x_{2,\min}) \le \min(x_{1,\max}, x_{2,\max}) \quad \text{and} \quad \max(y_{1,\min}, y_{2,\min}) \le \min(y_{1,\max}, y_{2,\max}) $$ Otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "051. The Convergence of Two Tetra-sided Polygons, Known as Rectangles",
    "description": {
      "content": "You will be given two opposite corners of two separate rectangles and you must determine whether they intersect or not. The first line will contain 4 integers separated by spaces, which respectively ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269051"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You will be given two opposite corners of two separate rectangles and you must determine whether they intersect or not.\n\nThe first line will contain 4 integers separated by spaces, which respectively ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ R_1 = [x_{1,\\min}, x_{1,\\max}] \\times [y_{1,\\min}, y_{1,\\max}] $ and $ R_2 = [x_{2,\\min}, x_{2,\\max}] \\times [y_{2,\\min}, y_{2,\\max}] $ be two axis-aligned rectangles, where:  ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments