cho.sh
Notes
Loading...

War - Local Battles

Time limit

2s

Memory limit

128 MB

Problem

Several army units are placed on a square battlefield. The battlefield is the region from coordinate (0, 0) to (X, X).

Every point on the battlefield is controlled by the army unit closest to that point. If a point lies on a boundary where multiple units are equally close, assigning that boundary point to either side does not change the total area. Each unit belongs either to your country or to the enemy country.

Compute the total area controlled by your country's units and the total area controlled by the enemy units.

Input

The first line contains the number of army units N and the side length X of the battlefield (1 <= N <= 100, 1 <= X <= 10,000). The battlefield is the square from (0, 0) to (X, X).

Each of the next N lines contains an army unit's position (a, b) and its country c. If c = 0, the unit belongs to your country; if c = 1, it belongs to the enemy country.

All input values are integers.

Output

Print the area controlled by your country's units and the area controlled by the enemy units on one line, each rounded to one digit after the decimal point.