#P5452. Kiana’s Walls and Patrolling Soldiers

    ID: 18684 Type: Default 1000ms 256MiB

Kiana’s Walls and Patrolling Soldiers

Kiana’s Walls and Patrolling Soldiers

In order to protect what she holds dearest, Kiana built n closed convex polygonal walls. These walls do not intersect, but they come in two types: the Craftsman Walls (built with bricks and rocks) and the Natural Walls (formed by trees and thorns).

To patrol the area within the walls, Kiana deploys two kinds of soldiers:

  • Soul Hunters: They grew up in the wild and can cross Natural Walls freely, but cannot cross Craftsman Walls.
  • Heavenly Knights: They soar in the sky and can fly over Craftsman Walls freely, but due to their beliefs they cannot cross Natural Walls.

Furthermore, Kiana uses her divine power m times to perform events of two types:

  1. Toggle the type of a wall (i.e. change a Craftsman Wall into a Natural Wall or vice versa).
  2. Directly teleport a soldier (either a Soul Hunter or a Heavenly Knight) to a coordinate \((x,y)\). It is guaranteed that the point is not on any wall and is at least \(10^{-3}\) away from any wall.

After each teleportation event, Kiana wishes to know the area of the region in which that soldier may move freely – considering that a soldier cannot cross the wall type that blocks his movement (Craftsman Walls block Soul Hunters and Natural Walls block Heavenly Knights). Note that because the walls are non‐intersecting convex polygons (possibly nested), they partition the plane into several regions; if the soldier is not confined by any blocking wall the accessible area is infinite.

Your task is to process the events online and, for every teleport event, output the area of the region in which the soldier is confined. Output the area with 6 decimal places; if the area is infinite, output the string Infinity.

inputFormat

The input begins with two integers n and m (n is the number of walls, m is the number of events).

Then follow n wall descriptions. Each wall description starts with an integer k (the number of vertices) followed by k pairs of real numbers representing the coordinates of its vertices (given in order) and a string which is either craftsman or natural indicating its type.

Then follow m events. Each event begins with an integer t:

  • If t = 1, an integer i follows (1-indexed index of the wall whose type is to be toggled).
  • If t = 2, the event is a teleport query. It is followed by an integer s representing the soldier type (1 for Soul Hunter and 2 for Heavenly Knight) and two real numbers x and y representing the teleport location.

It is guaranteed that the teleport location is not on any wall and is at least \(10^{-3}\) away from every wall.

outputFormat

For each teleport event (i.e. events where t = 2), output a line with the area of the accessible region for that soldier, with 6 decimal places. If the region is unbounded (infinite), output the string Infinity.

sample

2 4
3 0 0 10 0 0 10 craftsman
3 1 1 2 1 1 2 craftsman
2 1 0.5 0.5
1 2
2 1 0.5 0.5
2 2 5 5
49.500000

50.000000 Infinity

</p>