#P9828. [ICPC2020 Shanghai R] Octasection

    ID: 9192 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2020线段树上海Special JudgeO2优化ICPC

[ICPC2020 Shanghai R] Octasection

题目描述

At the Namomo Camp, a cute volunteer celebrates her birthday. Wowo buys her a huge cake. (The cake is so big that it has a 3D coordinate system inside.) There are nn cuboid shaped pieces of chocolates in\textbf{in} the cake. The ii-th (1in1\le i\le n) chocolate consists of all points (x,y,z)(x,y,z) such that $min\_x[i]\le x\le max\_x[i], min\_y[i]\le y\le max\_y[i], min\_z[i]\le z\le max\_z[i]$. min_x,max_x,min_y,max_y,min_z,max_zmin\_x,max\_x, min\_y,max\_y, min\_z, max\_z are 66 arrays of integers. Chocolates may overlap or touch each other.

The volunteer wants to distribute the cake to the campers of the Namomo Camp. To show off his knife skill, Wowo decides to cut the cake into pieces by exactly 33 cuts such that:

  • The first cut is a plane whose equation is x=ax=a for some integer aa decided by Wowo.
  • The second cut is a plane whose equation is y=by=b for some integer bb decided by Wowo.
  • The third cut is a plane whose equation is z=cz=c for some integer cc decided by Wowo.
  • Each chocolate is touched\textbf{touched} by at least one cut (i.e. each cuboid has a nonempty intersection with at least one plane).

Decide whether Wowo can cut the cake under the rules. If the answer is yes, output any possible solution.

输入格式

The first line contains a single integer nn (1n1000001\le n\le 100000).

The ii-th line of the next nn lines contains 66 integers $min\_x[i],max\_x[i], min\_y[i],max\_y[i], min\_z[i], max\_z[i]$ ($-10^9\le min\_x[i],max\_x[i], min\_y[i],max\_y[i], min\_z[i], max\_z[i]\le 10^9$, min_x[i]<max_x[i]min\_x[i]<max\_x[i], min_y[i]<max_y[i]min\_y[i]<max\_y[i], min_z[i]<max_z[i]min\_z[i]< max\_z[i]).

输出格式

If Wowo can cut the cake under the rules, the first line of the output should contain YES and the second line should contain 33 integers aa, bb and cc (109a,b,c109-10^9\le a, b, c\le 10^9). If Wowo cannot cut the cake under the rules, output only one line containing NO.

题目大意

有一个巨大的蛋糕,蛋糕里面有nn块立方体形状的巧克力,每块巧克力的位置由它的对角线坐标定义。一个人想通过三个平面切割这个蛋糕,每个平面的方程分别是x=ax=ay=by=bz=cz=c,其中aabbcc是整数。目标是选择aabbcc这样每块巧克力至少被一个切割平面触及。

输入由一个整数nn开始,表示巧克力的数量,后面跟着nn行,每行六个整数,分别代表每块巧克力在三维坐标系中的最小和最大xxyyzz坐标。

输出要求是如果存在这样的三个切割平面,第一行输出YES,第二行输出三个整数aabbcc。如果不存在,只输出NO

3
0 1 0 1 0 1
10 11 10 11 10 11
999999999 1000000000 999999999 1000000000 999999999 1000000000
YES
0 10 999999999
4
0 1 0 1 0 1
999999999 1000000000 0 1 0 1
0 1 999999999 1000000000 0 1
0 1 0 1 999999999 1000000000
YES
0 0 0