#P15923. [TOPC 2023] Gadget Construction

[TOPC 2023] Gadget Construction

题目描述

Grigory is a talented engineer who has a love in developing drones and, of course, geometry. As a skilled problem solver, he is able to come up with solutions in difficult situations, but today, he encountered a problem that his abilities alone are not enough to solve. Therefore, as his best sidekick, your task is to assist him.

There are nn cogs on the Cartesian plane. The ii-th cog is located at the coordinates (xi,yi)(x_i, y_i) and has a character cic_i that describes its color – “b” means it is a black cog, while “w” means it is a white cog. In addition, no three cogs lie on the same line.

Grigory wants to build a gadget using some cogs. To do this, he first chooses a subset SS that consists of 4 or more of the nn cogs. Then, a loop of chains is placed around the cogs. The loop is chosen such that:

  • Every cog in SS either touches the loop or lies in its interior.
  • The total length of chains is minimal.

For example, the image below shows the chains that would be placed for a chosen set of cogs.

:::align{center} :::

Finally, consider the cogs in SS that touch the loop. These are the most important cogs, so they cannot be interfering with each other. Therefore, any two adjacent cogs on the loop must have different colors, otherwise the resulting gadget won’t be working properly. If a cog in SS does not touch the loop, then it may have an arbitrary color.

How many different sets SS can Grigory choose to build a properly working gadget? Since the answer can be very large, find the value modulo 109+710^9 + 7.

输入格式

The first line contains an integer nn. Then nn lines follow. The ii-th line contains two integers xi,yix_i, y_i and a character cic_i denoting the coordinates and color of the ii-th cog.

输出格式

Print the number of sets SS that satisfy the conditions modulo 109+710^9 + 7.

4
0 0 w
1 0 b
1 1 w
0 1 b
1
6
0 0 w
0 4 b
1 2 w
3 2 b
4 0 b
4 4 w
9
4
0 0 b
1 0 w
1 1 w
0 1 b
0

提示

  • 4n5004 \le n \le 500
  • 108xi,yi108-10^8 \le x_i, y_i \le 10^8 for i=1,2,,ni = 1, 2, \dots, n
  • ci{b,w}c_i \in \{\texttt{b}, \texttt{w}\} for i=1,2,,ni = 1, 2, \dots, n
  • (xi,yi)(xj,yj)(x_i, y_i) \ne (x_j, y_j) for iji \ne j
  • No three cogs lie on the same line.