3D Geometry

시간 제한1초메모리 제한1024 MB

요약
각 테스트 케이스마다 축에 정렬된 사면체와 축에 정렬된 상자의 교집합 부피를 구한다.
난이도

어려움10점 중 8점

유형
기하, 수학, 구현
정답자
아직 제출이 없습니다

문제

An axis-aligned tetrahedron (also known as triangular pyramid) DABCDABC is a convex polyhedron in three dimension with vertices

  • D:(x_1,y_1,z_1)D: (x\_1, y\_1, z\_1),
  • A:(x_2,y_1,z_1)A: (x\_2, y\_1, z\_1),
  • B:(x_1,y_2,z_1)B: (x\_1, y\_2, z\_1),
  • C:(x_1,y_1,z_2)C: (x\_1, y\_1, z\_2).

Also, an axis-aligned cube PQRSDEFGPQRSDEFG is a convex polyhedron with vertices

  • P:(x_3,y_3,z_3)P: (x\_3, y\_3, z\_3),
  • Q:(x_3,y_3,z_4)Q: (x\_3, y\_3, z\_4),
  • R:(x_3,y_4,z_3)R: (x\_3, y\_4, z\_3),
  • S:(x_3,y_4,z_4)S: (x\_3, y\_4, z\_4),
  • D:(x_4,y_3,z_3)D: (x\_4, y\_3, z\_3),
  • E:(x_4,y_3,z_4)E: (x\_4, y\_3, z\_4),
  • F:(x_4,y_4,z_3)F: (x\_4, y\_4, z\_3),
  • G:(x_4,y_4,z_4)G: (x\_4, y\_4, z\_4).

Given an axis-aligned tetrahedron DABCDABC and an axis-aligned cube PQRSDEFGPQRSDEFG, find the volume of their intersection.

입력

The input consists of several test cases terminated by end-of-file. For each test case,

There are 44 lines, and the ii-th line contains three integers x_ix\_i, y_iy\_i, and z_iz\_i.

출력

For each test case, output a float which denotes the volume.

Your answer is considered correct if its absolute or relative error doesn't exceed 10−610^{-6}.

제한

  • −500≤x_i,y_i,z_i≤500-500 \leq x\_i, y\_i, z\_i \leq 500 for each 1≤i≤41 \leq i \leq 4
  • x_1≠x_2x\_1 \neq x\_2, y_1≠y_2y\_1 \neq y\_2, z_1≠z_2z\_1 \neq z\_2
  • x_3≠x_4x\_3 \neq x\_4, y_3≠y_4y\_3 \neq y\_4, z_3≠z_4z\_3 \neq z\_4
  • In each input, the number of test cases does not exceed 10510^5.

예제1

  1. 예제 1

    입력
    0 0 0
    1 1 1
    0 0 0
    1 1 1
    0 0 0
    2 2 2
    0 0 0
    1 1 1
    0 2 0
    2 0 2
    1 0 1
    0 1 0
    
    예상 출력
    0.166666667
    0.833333333
    0.166666667