Intersection of Cuboids

AtCoder
IDabc361_b
Time2000ms
Memory256MB
Difficulty
> You are trying to implement collision detection in a 3D game. In a $3$\-dimensional space, let $C(a,b,c,d,e,f)$ denote the cuboid with a diagonal connecting $(a,b,c)$ and $(d,e,f)$, and with all faces parallel to the $xy$\-plane, $yz$\-plane, or $zx$\-plane. (This definition uniquely determines $C(a,b,c,d,e,f)$.) Given two cuboids $C(a,b,c,d,e,f)$ and $C(g,h,i,j,k,l)$, determine whether their intersection has a positive volume. ## Constraints * $0 \leq a < d \leq 1000$ * $0 \leq b < e \leq 1000$ * $0 \leq c < f \leq 1000$ * $0 \leq g < j \leq 1000$ * $0 \leq h < k \leq 1000$ * $0 \leq i < l \leq 1000$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $a$ $b$ $c$ $d$ $e$ $f$ $g$ $h$ $i$ $j$ $k$ $l$ [samples]
Samples
Input #1
0 0 0 4 5 6
2 3 4 5 6 7
Output #1
Yes

The positional relationship of the two cuboids is shown in the figure below, and their intersection has a volume of $8$.
![image](https://img.atcoder.jp/abc361/12ad1f07f2801946704198807bbb3395.png)
Input #2
0 0 0 2 2 2
0 0 2 2 2 4
Output #2
No

The two cuboids touch at a face, where the volume of the intersection is $0$.
Input #3
0 0 0 1000 1000 1000
10 10 10 100 100 100
Output #3
Yes
API Response (JSON)
{
  "problem": {
    "name": "Intersection of Cuboids",
    "description": {
      "content": "> You are trying to implement collision detection in a 3D game. In a $3$\\-dimensional space, let $C(a,b,c,d,e,f)$ denote the cuboid with a diagonal connecting $(a,b,c)$ and $(d,e,f)$, and with all fa",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc361_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "> You are trying to implement collision detection in a 3D game.\n\nIn a $3$\\-dimensional space, let $C(a,b,c,d,e,f)$ denote the cuboid with a diagonal connecting $(a,b,c)$ and $(d,e,f)$, and with all fa...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments