問題一覧 > 通常問題

No.622 Point Inside or Outside a Triangular Prism

レベル : / AI推定難易度 : 1325 / 実行時間制限 : 1ケース 1.500秒 / メモリ制限 : 256 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 46
作問者 : ciel / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1786 / 自分の提出
問題文最終更新日: 2026-06-25 13:15:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2017 (順位表) の他の問題:

Problem Statement

You are given 4 points A, B, C, D in 3-dimensional space. Consider the triangular prism obtained by extending triangle ABC in the direction perpendicular to the plane containing triangle ABC (plane ABC). Determine whether point D lies inside this prism. Of course, plane ABC is not necessarily parallel to the XY plane.
It is guaranteed that the distance between "the projection of point D onto plane ABC" and any side of triangle ABC is at least 0.01.

Input

$x_1$ $y_1$ $z_1$
$x_2$ $y_2$ $z_2$
$x_3$ $y_3$ $z_3$
$x_4$ $y_4$ $z_4$

$x_i,y_i,z_i: i(1 \le i \le 4)$-th point's $x$-coordinate, $y$-coordinate, $z$-coordinate (integers)
$-10^{6} \le x_i,y_i,z_i \le 10^6$

Output

Print YES if the point lies inside the triangular prism, and NO otherwise, on 1 line.
Do not print anything else.

Sample

Sample 1
Input
0 0 0
2 0 0
1 2 0
1 1 1
Output
YES

In this case, triangle ABC is parallel to the XY plane, so you can simply project point D onto the XY plane and perform a point-in-triangle test.

Sample 2
Input
3 0 0
0 3 0
0 0 3
1 1 9
Output
NO

In this case, triangle ABC is not parallel to the XY plane.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。