10903: ABC361 - B - Intersection of Cuboids
[Creator : ]
Description
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.
Input
The input is given from Standard Input in the following format:
```
$a$ $b$ $c$ $d$ $e$ $f$
$g$ $h$ $i$ $j$ $k$ $l$
```
```
$a$ $b$ $c$ $d$ $e$ $f$
$g$ $h$ $i$ $j$ $k$ $l$
```
Output
Print
Yes
if the intersection of the two cuboids has a positive volume, and No
otherwise.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.
Sample 1 Input
0 0 0 4 5 6
2 3 4 5 6 7
Sample 1 Output
Yes
The positional relationship of the two cuboids is shown in the figure below, and their intersection has a volume of $8$.
Sample 2 Input
0 0 0 2 2 2
0 0 2 2 2 4
Sample 2 Output
No
The two cuboids touch at a face, where the volume of the intersection is $0$.
Sample 3 Input
0 0 0 1000 1000 1000
10 10 10 100 100 100
Sample 3 Output
Yes