#abc361b. B - Intersection of Cuboids

B - Intersection of Cuboids

Score : 250250 points

问题陈述

你正在尝试在3D游戏中实现碰撞检测。

在三维空间中,让 C(a,b,c,d,e,f)C(a,b,c,d,e,f) 表示一个长方体,其对角线连接点 (a,b,c)(a,b,c)(d,e,f)(d,e,f),并且所有面都与 xyxy 平面、yzyz 平面或 zxzx 平面平行。 (这个定义唯一确定了 C(a,b,c,d,e,f)C(a,b,c,d,e,f)。)

给定两个长方体 C(a,b,c,d,e,f)C(a,b,c,d,e,f)C(g,h,i,j,k,l)C(g,h,i,j,k,l),确定它们的交集是否具有正体积。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are trying to implement collision detection in a 3D game.

In a 33-dimensional space, let C(a,b,c,d,e,f)C(a,b,c,d,e,f) denote the cuboid with a diagonal connecting (a,b,c)(a,b,c) and (d,e,f)(d,e,f), and with all faces parallel to the xyxy-plane, yzyz-plane, or zxzx-plane.
(This definition uniquely determines C(a,b,c,d,e,f)C(a,b,c,d,e,f).)

Given two cuboids C(a,b,c,d,e,f)C(a,b,c,d,e,f) and C(g,h,i,j,k,l)C(g,h,i,j,k,l), determine whether their intersection has a positive volume.

Constraints

  • 0a<d10000 \leq a < d \leq 1000
  • 0b<e10000 \leq b < e \leq 1000
  • 0c<f10000 \leq c < f \leq 1000
  • 0g<j10000 \leq g < j \leq 1000
  • 0h<k10000 \leq h < k \leq 1000
  • 0i<l10000 \leq i < l \leq 1000
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

aa bb cc dd ee ff

gg hh ii jj kk ll

Output

Print Yes if the intersection of the two cuboids has a positive volume, and No otherwise.

Sample Input 1

0 0 0 4 5 6
2 3 4 5 6 7

Sample Output 1

Yes

The positional relationship of the two cuboids is shown in the figure below, and their intersection has a volume of 88.

Sample Input 2

0 0 0 2 2 2
0 0 2 2 2 4

Sample Output 2

No

The two cuboids touch at a face, where the volume of the intersection is 00.

Sample Input 3

0 0 0 1000 1000 1000
10 10 10 100 100 100

Sample Output 3

Yes