103611: [Atcoder]ABC361 B - Intesection of Cuboids

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:8 Solved:0

Description

Score : $250$ points

Problem Statement

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$

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 $8$.


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 $0$.


Sample Input 3

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

Sample Output 3

Yes

Output

得分:250分

问题陈述

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

在三维空间中,记$C(a,b,c,d,e,f)$为一个以$(a,b,c)$和$(d,e,f)$为对角线的长方体,且所有的面都平行于$xy$-平面、$yz$-平面或$zx$-平面。
(这个定义唯一确定了$C(a,b,c,d,e,f)$。)

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

约束条件

  • $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$
  • 所有输入值都是整数。

输入

输入从标准输入以以下格式给出:

$a$ $b$ $c$ $d$ $e$ $f$
$g$ $h$ $i$ $j$ $k$ $l$

输出

如果两个长方体的交集具有正体积,则打印Yes,否则打印No


样本输入1

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

样本输出1

Yes

两个长方体的位置关系如下图所示,它们的交集体积为$8$。


样本输入2

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

样本输出2

No

两个长方体在面上接触,交集的体积为$0$。


样本输入3

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

样本输出3

Yes

加入题单

上一题 下一题 算法标签: