SK C&C E-PRJ팀 Programmer 구인 Site

2008년 9월 9일 화요일

Overlapping Air Traffic Control Zones

Overlapping Air Traffic Control Zones

Optimization of air traffic flow is one of the essential ways for airlines to maintain economic viability. All too often, however, weather and other anomalous conditions disrupt air traffic flow resulting in significant costs. Automation systems for optimizing flows are not currently able to quickly reconfigure when path planning must account for dynamic conditions such as moving weather systems. Human intervention is usually used to decide route modifications.

Decisions on route modification for one aircraft must take into account neighboring aircraft safe zones in order to minimize possible collision risks. We will consider a 3D model in which the safe zone for one aircraft is represented as a parallelepiped.

Evaluation of aircraft collision risks, in this model, can be done by calculating the volume of the intersecting safe zones of the aircrafts in a given air traffic control zone. In other words, we need to be able to determine the volume of intersecting parallelepipeds.

Problem

Consider a number of parallelepipeds in space, having all the edges parallel to the axes. Your task is to write a program that outputs the volume occupied simultaneously by two or more parallelepipeds. Each parallelepiped is characterized by 6 integer values, the coordinates of two of its vertices

(x1,y1,z1), (x2, y2,z2) with x1 < x2y1 < y2 and z1 < z2

Input

The input file contains several test cases, each of them consists of an integer 0 ≤ n ≥ 15 in the first line followed by n lines of 6-tuples of integers describing the parallelepipeds. The total area occupied does not exceed 5x108.

Output

For each test case, output on a line by itself an integer corresponding to the total volume occupied simultaneously by two or more parallelepipeds.

Sample Input

  5
1 1 3 3 3
1 1 1 3 3 3
1 1 1 3 3 3
400000000 400000000 400000000 400000001 400000001 400000002
400000000 400000000 400000000 400000002 400000004 400000001

Sample Output

  9

댓글 없음:

기여자